Guest User

Untitled

a guest
Dec 7th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. #include<iomanip>
  4. using std::setw;
  5. using std::setprecision;
  6.  
  7. const int person=5;
  8. const int product=6;
  9. int main(){
  10. int u=0;
  11. int s;//sale
  12.  
  13. int PERSON[person]={0};
  14. int PRODUCT[product];
  15. int SELL[6][7]={0};//人.商品
  16.  
  17. int TOTAL1[4]={0};//銷售金額
  18. int TOTAL2[5]={0};//商品銷售金額
  19.  
  20. cout<<"Enter the salesperson(1-4), product number(1-5), and total sales.\n"
  21. <<"Enter -1 for the salesperson to end input."<<endl;
  22.  
  23. do{int p,q;//代替值
  24. for(int i=0;i<person;i++){
  25. cin>>PERSON[i];
  26. p=PERSON[i];
  27. while(p=-1)
  28. break;
  29. }//end for i
  30. for(int j=0;j<product;j++){
  31. cin>>PRODUCT[j];
  32. q=PRODUCT[j];
  33.  
  34. }//end for j
  35.  
  36. cin>>SELL[p][q];
  37.  
  38. }ehile(u!=-1);
  39.  
  40.  
  41.  
  42. cout<<"The total sales for each salesperson are displayed at the end of each row,\n"
  43. <<"and the total sales for each product are displayed at the bottom of each\n"
  44. <<"column."<<endl;
  45. for(int x=1;x<product;x++)
  46. cout<<setw(10)<<x;
  47. cout<<setw(10)<<"Total\n";
  48. for(int y=1;y<person;y++){
  49. for(int z=1;z<product;z++){
  50. cout<<y<<setw(10)<<SELL[y][z];
  51. TOTAL1 [y]+=SELL[y][z];
  52.  
  53. }//end for z
  54. cout<<TOTAL1[y]<<endl;
  55. }//end for y
  56.  
  57. cout<<"Total";
  58.  
  59. for(int a=1;a<product;a++){
  60. for(int b=1;b<person;b++)
  61. TOTAL2[a]+=SELL[a][b];
  62. cout<<setw(10)<<TOTAL2[a];
  63. }//end for a
  64.  
  65.  
  66. system("pause");
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. }
Add Comment
Please, Sign In to add comment