找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 170|回复: 0

幫忙看看我錯在哪了,怎麽改

[复制链接]
发表于 2009-11-3 03:21:45 | 显示全部楼层 |阅读模式 IP:江苏扬州
#include<iostream>
#include<string>
#include<fstream.h>
class stu
{
char name[50];
double math,chinese,english,physics,biology,chemistry,average,sum;
public:
stu()
{
}
stu(char n[20],double ma,double chin,double eng,double phy,double bio,double che)
{
strcpy(name,n);
math=ma;
chinese=chin;
english=eng;
physics=phy;
biology=bio;
chemistry=che;
}
double getsum()
{
sum=chinese+english+math+physics+biology+chemistry;
return sum;
}
double getaver()
{
average=getsum()/6.0;
return average;
}
friend void main();
};


void main()
{
cout<<"请选择您需要的操作!"<<endl;
cout<<"操作:"<<endl;
cout<<"(0)数据录入"<<endl;
cout<<"(1)增加人员"<<endl;
cout<<"(2)删除人员"<<endl;
cout<<"(3)修改数据"<<endl;
cout<<"查询:"<<endl;
cout<<"(4)按总成绩查询"<<endl;
cout<<"(5)按姓名查询"<<endl;
cout<<"(6)输出所有学生的数据"<<endl;
cout<<"成绩名词"<<endl;
cout<<"(7)按总分查询排名"<<endl;
cout<<"(8)按语文查询排名"<<endl;
cout<<"(9)按数学查询排名"<<endl;
cout<<"(10)按英语查询排名"<<endl;
cout<<"(11)按物理查询排名"<<endl;
cout<<"(12)按生物查询排名"<<endl;   
cout<<"(13)按化学查询排名"<<endl;
cout<<"选择相关操作请输入相对的括号里的阿拉伯数字!"<<endl;
char p;char w;
stu *s[50];
ofstream *file[50];
int i=0;
int j=0;
bool flag2=0;
do
{
cin>>p;
if((p>='0'&&p<='15'))
flag2=1;
else
cout<<"指令错误!请重新输入:"<<endl;
}while(flag2==0);
do{
switch(p)
{
case '0':
{
char c;
char name[20];double math,chinese,english,physics,biology,chemistry;
do{
cout<<"请输入姓名"<<endl;
cin>>name;
cout<<"请输入数学成绩:"<<endl;
cin>>math;
cout<<"请输入语文成绩:"<<endl;
cin>>chinese;
cout<<"请输入外语成绩:"<<endl;
cin>>english;
cout<<"请输入物理成绩:"<<endl;
cin>>physics;
cout<<"请输入生物成绩:"<<endl;
cin>>biology;
cout<<"请输入化学成绩:"<<endl;
cin>>chemistry;
file[j]=new ofstream("d:\\document",ios::ate);
*file[j]<<"姓名"<<name<<"数学成绩"<<math<<"语文成绩"<<chinese<<"外语成绩"<<english<<"物理成绩"<<physics<<"生物成绩"<<biology<<"化学成绩"<<chemistry<<endl;
j++;
s[i]=new stu(name, math, chinese, english,physics,biology,chemistry);
i++;
cout<<"数据录入成功,想继续录入吗(y/n)"<<endl;
cin>>c;
flag2=0;
do
{
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
else
flag2=1;
}while(flag2==0);
}while(c=='y');
break;
}
case '4':
{
double t;char c;
do
{
int flag1=0;
cout<<"请输入你要查询学生的总成绩"<<endl;
cin>>t;
for(int q=0;q<i;q++)
{
if(s[q]->getsum()==t)
{
flag1=1;
cout<<"您要查询的学生是:"<<(*s[q]).name<<endl;
}
}
if(flag1==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}

case '5':
{
char n[20];int j=0;char c;
do{
int flag=0;
cout<<"请输入你要查询的学生姓名"<<endl;
cin>>n;
for(int j=0;j<i;j++)
{
if(strcmp(n,(*s[j]).name)==0)
{
flag=1;
cout<<"您要查询的学生是:"<<(*s[j]).name<<endl;
cout<<(*s[j]).name<<"的总成绩成绩是"<<(*s[j]).getsum()<<endl<<"平均成绩是:"<<(*s[j]).getaver()<<endl;
}
}
if(flag==0)
cout<<"对不起!您要查询的学生不存在!"<<endl;
cout<<"您想继续查询吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}
while(c=='y');
break;
}
case '1':
{
char name[20];double math,chinese,english,physics,biology,chemistry;
char c;
do
{
cout<<"请输入您要增加的学生的姓名:"<<endl;
cin>>name;
cout<<"请输入数学成绩:"<<endl;
c
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 13:17 , Processed in 0.187450 second(s), 12 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表