Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- #include<iomanip>
- using std::setw;
- using std::setprecision;
- const int person=5;
- const int product=6;
- int main(){
- int u=0;
- int s;//sale
- int PERSON[person]={0};
- int PRODUCT[product];
- int SELL[6][7]={0};//人.商品
- int TOTAL1[4]={0};//銷售金額
- int TOTAL2[5]={0};//商品銷售金額
- cout<<"Enter the salesperson(1-4), product number(1-5), and total sales.\n"
- <<"Enter -1 for the salesperson to end input."<<endl;
- do{int p,q;//代替值
- for(int i=0;i<person;i++){
- cin>>PERSON[i];
- p=PERSON[i];
- while(p=-1)
- break;
- }//end for i
- for(int j=0;j<product;j++){
- cin>>PRODUCT[j];
- q=PRODUCT[j];
- }//end for j
- cin>>SELL[p][q];
- }ehile(u!=-1);
- cout<<"The total sales for each salesperson are displayed at the end of each row,\n"
- <<"and the total sales for each product are displayed at the bottom of each\n"
- <<"column."<<endl;
- for(int x=1;x<product;x++)
- cout<<setw(10)<<x;
- cout<<setw(10)<<"Total\n";
- for(int y=1;y<person;y++){
- for(int z=1;z<product;z++){
- cout<<y<<setw(10)<<SELL[y][z];
- TOTAL1 [y]+=SELL[y][z];
- }//end for z
- cout<<TOTAL1[y]<<endl;
- }//end for y
- cout<<"Total";
- for(int a=1;a<product;a++){
- for(int b=1;b<person;b++)
- TOTAL2[a]+=SELL[a][b];
- cout<<setw(10)<<TOTAL2[a];
- }//end for a
- system("pause");
- }
Add Comment
Please, Sign In to add comment