-1
我不能輸出的銷售總數,所需的輸出必須是這樣的:如何總輸出
售貨員1個銷售額:20000個銷售15%
業務員2個銷量:15000個銷售15%
推銷員3名銷售:10000個銷售13%
售貨員4名銷售:5000個銷售13%
業務員5個銷量:12000個銷售13%
名推銷員6名銷售:25000個銷售20%
總銷售量:
20% - 1
15% - 2
13% - 3
這裏是我的代碼:
int a = 0;
int b = 0;
int c = 0;
for (int x = 1; x <= salesMan; x++)
{
if (sales[x] > 20000)
{
a = x + a;
cout << "Salesman " << x << " Sales: " << sales[x] << " 20%";
cout << "\n";
}
else if (sales[x] <= 20000 && sales[x] >= 15000)
{
b = x + b;
cout << "Salesman " << x << " Sales: " << sales[x] << " 15%";
cout << "\n";
}
else if (sales[x] < 15000 && sales[x] >= 0)
{
c = x + c;
cout << "Salesman " << x << " Sales: " << sales[x] << " 13%";
cout << "\n";
}
}
cout <<"20% - "<< a <<"\n";
cout <<"15% - "<< b <<"\n";
cout <<"13% - "<< c <<"\n";
S olve: a += 1
not a = x + a
< ---這段代碼增加了推銷員的索引,所以這就是爲什麼我不能得到我的答案。
謝謝@TZHX
您當前的輸出是什麼? –
'總銷售量: 20% - 6 15% - 3 13% - 12' – user3415509
你也許想'A + = 1'等,而不是增加你目前對指數的價值? – TZHX