有关成绩的c++设计

来源:百度知道 编辑:UC知道 时间:2024/05/26 03:55:39
将一个班30个学生的学号、姓名和三门课的成绩保存在Salary.dat文件中,然后读出并根据要求计算出平均成绩,最高分,最低分,统计优秀率,及格率,不及格率。
最后输出具有下列格式的结果:
number name courseA courseB courseC
201 zhangsan 67 74 75
202 Wangwu 77 80 81

平均 76.5 77.3 74
最高 85 80 82
最低 54 60 61
优秀率 7%
及格率 98%
不及格率 2%
c++程序设计急用,要调试好的,谢谢

#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;

void High(float,float&);
void Low(float,float&);
void Score(float,float,float,int&,int&,int&);
ifstream inData;
float total1=0,total2=0,total3=0;
int n=0,youxiu=0,jige=0,bujige=0;
float high1=0,high2=0,high3=0;
float low1=100,low2=100,low3=100;

int main()
{
int ID; //学号
string name; //名字
float mark1, mark2,mark3; //成绩
inData.open("salary.dat") ;
inData>>ID>>name>>mark1>>mark2>>mark3;
if(!inData)
{
cout<<"can't open the file"<<endl;
return 1;
}
cout<<"number name"<<" courseA "<<"courseB "<<"courseC "<<endl;
while(inData)
{
cout<<ID<<setw(10)<&