/*
Three-dimensional array
int a[x][y][z]
x: represents the number of days y: represents the salesperson z: represents the goods number
*/
#include <iostream>
using namespace std;
#include <iomanip>
void sale(int note[ ][4][5],int);
void peo(int note[][4][5],int);
void sin(int note[][4][5],int);
void main(){ int note[10][4][5];//Definition note for(int x=0;x<10;x++){//You can change x to a convenient number when testing cout<<"Please enter Note for "<<x+1<<" day\n"; for(int y=0;y<4;y++){ cout<<""<<y+1<<" employee:\n "; for(int z=0;z<5;z++){ cout<<"Sales of the "<<z+1<<" kind of goods:"; cin>>note[x][y][z]; } }
}
cout<<endl;
sale(note,2);cout<<endl;
peo(note,2);cout<<endl;
sin(note,2);cout<<endl;
}
void sale(int note[][4][5],int n){//The sales volume of each product per personint
count[4][5],count1;
for(int y=0;y<4; y++){ for(int z=0;z<5;z++){ count1=0; for(int x=0;x<n;x++){ count1+=note[x][y][z]; } count [y][z]=count1; } } cout<<setw(4)<<"Sales of each product per person:\n"; for(int j=0;j<4;j++){ cout<< Employee "<<j+1<<":\n"; for(int k=0;k<5;k++){ cout<<"The sales volume of goods "<<k+1<<" is "<<count[j][k]<<endl ; } } } void peo(int note[][4][5],int n){//ranking of employees
int count[4][2],count1;//Statistics of total sales per person
int p,s;//Intermediate variable of personnel number and total amount when sorting
for(int y=0;y<4;y++){ count1 =0; for(int z=0;z<5;z++){ for(int x=0;x<n;x++){ count1+=note[x][y][z]; } } count[y] [0]=y+1; count[y][1]=count1; } for(int j=0;j<3;j++){ for(int k=0;k<3-j;k++){ if (count[k][1]<count[k+1][1]){ s=count[k+1][1], p=count[k+1][0], count[k+1] [1]=count[k][1], count[k+1][0]=count[k][0], count [k][1]=s, count[k][0]=p; }
}
}
cout<<setw(4)<<"employee rank:\n";
for(int q=0;q<4;q++){ cout<<"th"<<q+1<<"employee For: "<<count[q][0]<<"employee\n"<<setw(2); cout<<"The total sales are:"<<count[q][1]<<endl; } } void sin(int note[][4][5],int n){//The ranking of goods and total sales of goods int count[5][2],count1;//Statistics of sales and goods number int p,s;//中间变量 for(int z=0;z<5;z++){ count1=0; for(int x=0;x<n;x++){ for(int y=0;y<4;y++){ count1+=note[x][y][z]; } } count[z][0]=z+1; count[z][1]=count1; }
for(int j=0;j<4;j++){ for(int k=0;k<4-j;k++){ if(count[k][1]<count[k+1][1]) s=count[k+1][1], p=count[k+1][0], count[k+1][1]=count[k][1], count[k+1][0 ]=count[k][0], count[k][1]=s, count[k][0]=p; } } cout <<setw(4)<<"Ranking of goods and total sales of goods :\n"; for(int q=0;q<5;q++){ cout<<"The total sales volume of "<<q+1<<" is:"<<count[q][0 ]<<"Goods of type No."<<setw(4); cout<<"The total sales volume is:"<<count[q][1]<<endl; } }