/*
三维数组
int a[x][y][z]
x:代表天数 y:代表售货员 z:代表货物号
*/
#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];//定义便条
for(int x=0;x<10;x++){//进行测试时可以将x修改为方便使用的数字
cout<<"请输入第"<<x+1<<"天的便条\n";
for(int y=0;y<4;y++){
cout<<"第"<<y+1<<"位员工:\n";
for(int z=0;z<5;z++){
cout<<"第"<<z+1<<"种货物的销售额:";
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){//每个人每种产品销售额
int 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)<<"每个人每种产品销售额:\n";
for(int j=0;j<4;j++){
cout<<"第"<<j+1<<"位员工:\n";
for(int k=0;k<5;k++){
cout<<"第"<<k+1<<"种货物销售额为"<<count[j][k]<<endl;
}
}
}
void peo(int note[][4][5],int n){//员工的排名
int count[4][2],count1;//统计每人总销售额
int p,s;//排序时人员编号和总额的中间变量
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)<<"员工的排名:\n";
for(int q=0;q<4;q++){
cout<<"第"<<q+1<<"名员工为:"<<count[q][0]<<"号员工\n"<<setw(2);
cout<<"总销售额为:"<<count[q][1]<<endl;
}
}
void sin(int note[][4][5],int n){//货物和货物总销售额的排名
int count[5][2],count1;//统计销售额和货物编号
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)<<"货物和货物总销售额的排名:\n";
for(int q=0;q<5;q++){
cout<<"销售额总量第"<<q+1<<"名的为:"<<count[q][0]<<"号类型的货物"<<setw(4);
cout<<"总销售额为:"<<count[q][1]<<endl;
}
}