第十七周项目6--学生成绩统计(1,2,3)

/*
 *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;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值