# P1: 职工工资统计

P1: 职工工资统计

C：
#include <stdio.h>
using namespace std;
struct WageList
{
char name[10];  //姓名
double baseWage;   //基本工资
double bonus;      //奖金
double total;       //总额
};
int main( )
{
WageList wage[100];
//************* begin*****************
//************* end *****************
for(i=0; i<n; i++)
{
printf("%s %.2lf %.2lf %.2lf\n",wage[i].name,wage[i].baseWage,wage[i].bonus,wage[i].total);
}
printf("average:%.2lf\n",aver);
return 0;
}
C++：
#include <iostream>
#include <iomanip>
using namespace std;
struct WageList
{
char name[10];  //姓名
double baseWage;   //基本工资
double bonus;      //奖金
double total;       //总额
};
int main( )
{
WageList wage[100];
//************* begin*****************
//************* end *****************
cout <<setiosflags(ios::fixed)<<setprecision(2);
for(i=0; i<n; i++)
{
cout<<wage[i].name<<" "<<wage[i].baseWage<<" "<<wage[i].bonus<<" "<<wage[i].total<<endl;
}
cout<<"average:"<<aver<<endl;
return 0;
}

``````3
Tom 3425.8 480.5
Jerry 4975.64 730.23
Jack 2240 520.35``````

``````Tom 3425.80 480.50 3906.30
Jerry 4975.64 730.23 5705.87
Jack 2240.00 520.35 2760.35
average:4124.17``````

``````
#include <stdio.h>
#include <stdlib.h>
struct WageList
{
char name[10];  //姓名
double baseWage;   //基本工资
double bonus;      //奖金
double total;       //总额
};
int main( )
{
struct WageList wage[100]; int n,i;
double aver=0;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%s%lf%lf",&wage[i].name,&wage[i].baseWage,&wage[i].bonus);
float sum=0;
for(int i=0;i<n;i++)
{
wage[i].total=wage[i].baseWage+wage[i].bonus;
sum+=wage[i].total;
}
aver=sum/n;

for(i=0; i<n; i++)
{
printf("%s %.2lf %.2lf %.2lf\n",wage[i].name,wage[i].baseWage,wage[i].bonus,wage[i].total);
}
printf("average:%.2lf\n",aver);
return 0;
}``````

``````#include <iostream>
#include <iomanip>
using namespace std;
struct WageList
{
char name[10];  //姓名
double baseWage;   //基本工资
double bonus;      //奖金
double total;       //总额
};
int main( )
{
WageList wage[100];
//************* begin*****************
int n,i;
double sum=0,aver;
cin>>n;
for(i=0; i<n; i++)
{
cin>>wage[i].name>>wage[i].baseWage>>wage[i].bonus;
wage[i].total=wage[i].baseWage+wage[i].bonus;
sum+=wage[i].total;
}
aver=sum/n;
//************* end *****************
cout <<setiosflags(ios::fixed)<<setprecision(2);
for(i=0; i<n; i++)
{
cout<<wage[i].name<<" "<<wage[i].baseWage<<" "<<wage[i].bonus<<" "<<wage[i].total<<endl;
}
cout<<"average:"<<aver<<endl;
return 0;
}
``````