第二周(项目一)——学生成绩统计
2014-03-05 18:50
260 查看
/* 烟台大学计算机学院学生 *All rights reserved. *文件名称:学生成绩统计 *作者:王洪海 *完成日期:2013年3月5日 *版本号:v1.0 1*对任务及求解方法的描述部分:学生成绩统计 我的程序: */ #include <iostream> using namespace std; struct Student { char num[13]; char name[10]; int cpp; int math; int english; double score; double average; }; const int n=3; int main( ) { int i, j; double p,k=0; //定义结构体数组 Student stu ; //写出代码,实现要求的功能 cout<<"请输入学号、姓名、c++、高数、英语成绩:"<<endl; 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].cpp+stu[i].math+stu[i].english)/3.0; } cout<<"学号"<<"\t"<<"姓名"<<"\t"<<"总分"<<"\t"<<"平均分"<<endl; for(i=0;i<n;i++) { cout<<stu[i].num<<"\t"<<stu[i].name<<"\t"<<stu[i].score<<"\t"<<stu[i].average<<endl; } for(j=0;j<n;j++) { k=stu[j].average+k; } p=k/n; cout<<"所有同学的平均值是:"<<p<<endl; return 0; }
运行结果,如下图:
相关文章推荐
- JNDI学习总结
- Could not load the Tomcat server configuration at \Servers\Tomcat v7.0 Server at localhost-config.
- openfire_插件开发-jsp/servlet
- android:clipChildren属性
- STL 之 stack - queue
- 当当结盟一号店
- STL 之 heap
- 基于HOST宿主机制作一个简单的可启动的Linux
- HeapAlloc内部算法
- ASP.Net连接Sqlserver简单举例
- ios 1 cocoa
- Android自定义照相机实现(拍照、保存到SD卡,利用Bundle在Acitivity交换数据)
- 浮点数的比较
- [转]How to handle Failed Rows in a Data Flow
- 08-IOSCore - App Store、国际化/本地化
- STL 之 deque
- java函数执行超时强制返回
- cookie 和session 的区别详解
- 关于Python中的for循环控制语句
- Matlab/Simulink与Arduino——资源小收集