蜘蛛故事视频大全图片:C++高手请帮忙帮我的程序添加几个功能,做的好可以加分!谢谢了!

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/12 19:03:14
这阵课程设计,弄了这个程序。结果后来一看还需要存储查询和删除功能。似乎要用到I/O流的什么东西,那些东西我没有学过哦。搞不太清楚怎么做。马上就要交了,急死人,麻烦各位高手帮忙做一下这3个功能吧。谢谢了先~另外这个程序是要在VC下运行了~~再谢谢下`~
#include<iostream.h>
#include<string.h>

class students
{
private:
char name[20];
int number;
public:
void getdata()
{
cout<<"Input the student's NO:";
cin>>number;
cout<<"Input the student's name:";
cin>>name;
}
void showdata()
{
cout<<number<<" "<<name<<" ";
}
};

class mark:public students
{
public:
int English,Maths,Chinese,Total;
public:
void getdata()
{
students::getdata();
cout<<"Input the student's English score:";
cin>>English;
cout<<"Input the student's Chinese score:";
cin>>Chinese;
cout<<"Input the student's Maths score:";
cin>>Maths;
}
void sumdata()
{
Total=English+Maths+Chinese;
}
void showdata()
{
students::showdata();
cout<<English<<" "<<Chinese<<" "<<Maths<<" "<<Total<<endl;
}
};
int main()
{
int n=0;
int sumMaths=0;
int sumEnglish=0;
int sumChinese=0;
float Eaverage,Maverage,Caverage;
char choice;
const MAX=50;
mark stu[MAX];

do
{
stu[n].getdata();
sumMaths+=stu[n].Maths;
sumChinese+=stu[n].Chinese;
sumEnglish+=stu[n].English;
stu[n].sumdata();
n++;
done:
cout<<"Enter another?(y/n):";
cin>>choice;
if(choice!='y'&&choice!='n')
{
cout<<"Please choice y or n:"<<endl;
goto done;
}

}
while(choice!='n');

Eaverage=sumEnglish/n;
Maverage=sumMaths/n;
Caverage=sumChinese/n;

cout<<"number"<<" "<<"name"<<" "<<"English"<<" "<<"Chinese"<<" "<<"Maths"<<" "<<"Total"<<endl;

for(int num =0;num<n;num++)
{
stu[num].showdata();
stu[num].sumdata();
}
cout<<"The average score of English is:"<<Eaverage<<endl;
cout<<"The average score of Maths is:"<<Maverage<<endl;
cout<<"The average score of Chinese is:"<<Caverage<<endl;

return 0;
}
这是一串各科成绩运算平均分的代码。需要添加的是可以把得到的信息储存到一个.TXT文件下和可以在运行程序后提取删除他们。

cls不可以么?我也不是很懂 等高手来~!!!!

看你的课本
我们也做个这个题目
我就是直接把那个课本的给融合下 就可以了
课本是 潭浩强 啊