/*
*Copyright(c)2014,烟台大学计算机学院
*Allrights reserved.
*文件名称:MADE2.cpp
*作 者:张生栋
*完成日期:2014年12月23日
*问题描述:求出每名同学的总分和均分,并存储在结构体数组中
*输入描述:N名同学的信息
*输出描述:输出每位同学的信息学号,姓名,总分和均分
*版 本 号:v1.0
*
*/
#include <iostream>
#include<iomanip>
using namespace std;
struct Student
{
char num[13];
char name[10];
int cpp;
int math;
int english;
int score;
double average;
};
const int N=3;
int main( )
{
int i,j,k;
cout<<"请输入学生的学号,姓名及c++,高数,英语的成绩"<<endl;
Student stu[N];
//写出代码,实现要求的功能
for(i=0;i<N;i++)
{
cin>>stu[i].num>>stu[i].name>>stu[i].cpp>>stu[i].math>>stu[i].english;
stu[i].score=stu[i].cpp+stu[i].math+stu[i].english;
stu[i].average=stu[i].score/3;
}
cout<<setw(5)<<"学号"<<setw(5)<<"姓名"<<setw(5)<<"总分"<<setw(5)<<"均分"<<endl;
for(j=0;j<N;j++)
cout<<setw(5)<<stu[j].num<<setw(5)<<stu[j].name<<setw(5)<<stu[j].score<<setw(5)<<stu[j].average<<endl;
double a,s=0;
for(k=0;k<N;k++)
{
s+=stu[k].average;
}
a=s/N;
cout<<"所有同学均分的均值是:"<<a<<endl;
return 0;
}
第十七周项目6--学生成绩统计(1,2,3)
最新推荐文章于 2020-12-12 20:36:07 发布