相关疑难解决方法(0)

c ++使用结构排序

我很难解决这个问题,需要一种客户名称,客户ID,最后是应付金额.我有整个程序,但无法弄清楚进行排序所需的最后一个原型.我有一个名为Customers的结构,我也将提供int main()部分.我只需要任何帮助来启动原型SortData().

struct Customers {
    string Name;
    string Id;
    float OrderAmount;
    float Tax;
    float AmountDue;
};

const int MAX_CUSTOMERS = 1000;
bool MoreCustomers(int);
Customers GetCustomerData();
void OutputResults(Customers [], int);
void SortData(const int, const int, Customers []);

int main() {
    Customers c[MAX_CUSTOMERS]; 
    int Count = 0;      
    do {
      c[Count++] = GetCustomerData();   
    } while (MoreCustomers(Count));     


    for (int i = 0; i < Count; i++) {
        c[i].Tax = 0.05f * c[i].OrderAmount;        
        c[i].AmountDue = c[i].OrderAmount + c[i].Tax;   
    }

    SortData(0, Count, c);     //0:Sorts by customer …
Run Code Online (Sandbox Code Playgroud)

c++ arrays sorting struct bubble-sort

15
推荐指数
2
解决办法
5万
查看次数

标签 统计

arrays ×1

bubble-sort ×1

c++ ×1

sorting ×1

struct ×1