| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 835 人关注过本帖
标题:幫忙看看我錯在哪了,怎麽改
只看楼主 加入收藏
weiwei052
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2007-11-24
收藏
 问题点数:0 回复次数:1 
幫忙看看我錯在哪了,怎麽改
#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;
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;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '2':
{
char name[20];bool flag3=0;char c;
do{
cout<<"请输入您要删除的学生姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
flag3=1;
i--;
do{
s[h]=s[h+1];
h++;
}while(h<=i);
}
}
if(flag3==0)
cout<<"您要求删除的对象本来就不存在!请检查输入的正确性!";
cout<<"要继续删除吗?(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}
case '3':
{
char name[20];double mat,chin,eng,phy,bio,che;flag2=0;
char c;
do
{
cout<<"请输入您要修改的学生的姓名:"<<endl;
cin>>name;
for(int h=0;h<i;h++)
{
if(strcmp(name,s[h]->name)==0)
{
flag2=1;
cout<<"请输入新的数学成绩:"<<endl;
cin>>mat;
cout<<"请输入新的语文成绩:"<<endl;
cin>>chin;
cout<<"请输入新的外语成绩:"<<endl;
cin>>eng;
cout<<"请输入新的物理成绩:"<<endl;
cin>>phy;
cout<<"请输入新的生物成绩:"<<endl;
cin>>bio;
cout<<"请输入新的化学成绩:"<<endl;
cin>>che;
s[h]->chinese=chin;
s[h]->math=mat;
s[h]->english=eng;
s[h]->physics=phy;
s[h]->biology=bio;
s[h]->chemistry=che;
cout<<"数据修改成功!";
}
}
if(flag2==0)
{
cout<<"您要修改的学生本来就不存在!请检查重新输入!"<<endl;
}
cout<<"想继续修改吗(y/n)"<<endl;
cin>>c;
if(c!='y'&&c!='n')
{
cout<<"指令错误!请重新输入!"<<endl;
cin>>c;
}
}while(c=='y');
break;
}

case '6':
{
cout<<"本系统所有学生数据如下:"<<endl;
if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!"<<endl;
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<(*s[k]).getsum()
<<"平均分:"<<" "<<(*s[k]).getaver()<<endl;
}
break;
}
case '7':
{
int t;stu b;

cout<<"本系统所以学生排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->getsum())<(s[y]->getsum()))
t=y;
if(t!=x)
{
b=*s[x];
*s[x]=*s[t];
*s[t]=b;
}
}
}
if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english"<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
break;
}
case '8':
{
int t;stu b;

cout<<"本系统所以学生语文排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->chinese)<(s[y]->chinese))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
break;
}
case '9':
{
int t;stu b;

cout<<"本系统所以学生数学排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->math)<(s[y]->math))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
break;
}
case '10':
{
int t;stu b;

cout<<"本系统所以学生英语排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->english)<(s[y]->english))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
}
break;
}
case '13':
{
int t;stu b;

cout<<"本系统所以学生化学排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->chemistry)<(s[y]->chemistry))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
}
break;
case '12':
{
int t;stu b;

cout<<"本系统所以学生生物排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->biology)<(s[y]->biology))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
}
break;
case '11':
{
int t;stu b;

cout<<"本系统所以学物理排名如下:"<<endl;
for(int x=0;x<i-1;x++)
{
t=x;
for(int y=x+1;y<i;y++)
{
if((s[t]->physics)<(s[y]->physics))
t=y;
if(t!=x)
{
b=*s[t];
*s[t]=*s[x];
*s[x]=b;
}
}
}

if(i==0)
cout<<"管理系统中没有录入数据或者数据已经被删除!";
for(int k=0;k<i;k++)
{
cout<<k+1<<" "<<"姓名:"<<" "<<s[k]->name<<
"语文:"<<" "<<s[k]->chinese<<"数学:"<<" "<<s[k]->math
<<"外语:"<<" "<<s[k]->english<<"物理:"<<" "<<s[k]->physics<<"生物:"<<" "<<s[k]->biology<<"化学:"<<" "<<s[k]->chemistry<<"总分:"<<" "<<s[k]->getsum()
<<"平均分:"<<" "<<s[k]->getaver()<<endl;
}
}
break;

cout<<"您想继续进行其他操作吗?(y/n)"<<endl;
bool flag4=0;
do
{
cin>>w;
if(w!='y'&&w!='n')
cout<<"指令错误!请重新输入!"<<endl;
else
flag4=1;
}while(flag4==0);
if(w=='y')
cout<<"请输入操作代码(0 录入/4 按总分查询/5 按姓名查询/1 增加人员/2 删除人员/3 修改数据/6 显示所有成员数据/7 按总分排名/8 按语文排名/9按数学排名/y按英语排名/p按物理排名/b按生物排名/c按化学排名)"<<endl;
cin>>p;
}while(w=='y');
for(int x=0;x<i;x++)
{
delete s[x];
cout<<"delete all members!"<<endl;
}

}

 

编译器上面显示的我去改,但我不知道怎么改,我认为是对的,麻烦各位大哥看看
--------------------Configuration: sdasdas - Win32 Debug--------------------
Compiling...
sdasdas.cpp
f:\dadsadasdasda\sdasdas.cpp(327) : error C2143: syntax error : missing ';' before 'string'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xce'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xef'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xc0'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xed'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xa3'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xba'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xc9'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xfa'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xce'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xef'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xa3'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xba'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xbb'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xaf'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xd1'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xa7'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xa3'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xba'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xd7'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xdc'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xb7'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xd6'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xa3'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2018: unknown character '0xba'
f:\dadsadasdasda\sdasdas.cpp(327) : error C2001: newline in constant
f:\dadsadasdasda\sdasdas.cpp(328) : error C2296: '<<' : illegal, left operand has type 'char [81]'
f:\dadsadasdasda\sdasdas.cpp(328) : error C2297: '<<' : illegal, right operand has type 'char [9]'
f:\dadsadasdasda\sdasdas.cpp(429) : error C2046: illegal case
f:\dadsadasdasda\sdasdas.cpp(461) : error C2046: illegal case
f:\dadsadasdasda\sdasdas.cpp(493) : error C2046: illegal case
执行 cl.exe 时出错.

sdasdas.exe - 1 error(s), 0 warning(s)
搜索更多相关主题的帖子: english average biology include public 
2007-11-28 12:36
ssj_560@163.com
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2007-11-28
收藏
得分:0 
[bold]实验目的:[/bold]学会用C++语言和数据结构链表编程实现信息管理系统
[bold]实验要求:[/bold]包括系统设计要求,开发环境要求,技术文档要求三部分
[bold]系统设计要求[/bold]
[bold]1.
[/bold][bold]学生成绩管理系统中不同使用单位(用户)的学生人数事先无法确定.[/bold]
[bold]2.
[/bold]该学生成绩管理系统要求有学生[bold]成绩录入,查询,修改,删除,保存文件.[/bold]
3.
[bold]系统使用文字菜单,用户通过选择菜单项的编号,实现系统对子模块的调用.也可用windows界面下的菜单栏、弹出式菜单、下拉菜单[/bold]
4.
[bold]每个班级每门课程的成绩可以从学生的成绩总表提取出子表并存储成一个文本文件,以便在windows的notebook或者Microsoft word下打印,规定该文本文件名由班级号和课程名拼音字符串构成.输入班级号和课程名字符串后自动生成文件名.如1班,语文,则文件名为:c1yuwen.txt[/bold]
[bold]5.
[/bold]每个学生学习的课程有[bold][underline]语文,英语,数学,物理,化学,生物.[/underline][/bold]
6.
学生的成绩总表结构约定为(学号,姓名,课程名,平时成绩,期末成绩,总评成绩).总评成绩由程序自动计算,总评成绩=平时成绩30%+期末成绩70%.
7.
学号是一个9位整数构成的字符串, 学号的编码规则:入学年份+在读年级+在读班级+班内编号;入学年份用4位整数构成字符串,如2003年入学则表示为:[font=Times New Roman]”[/font]2003[font=Times New Roman]”[/font];在读年级用1位整数构成字符串,如正在1年级读书则表示为:[font=Times New Roman]”[/font]1[font=Times New Roman]”[/font];在读班级用2位整数构成字符串,如正在1班读书则表示为:[font=Times New Roman]”[/font]01[font=Times New Roman]”[/font];班内编号用2位整数构成字符串,如在班内编号为23号则表示为:[font=Times New Roman]”[/font]23[font=Times New Roman]”[/font]
[bold]技术文档要求:[/bold]
按照软件工程技术文档编写要求进行。要求[bold]流程图绘制规范[/bold],模块功能描述清晰,数据字典齐全。
[bold]实验内容:[/bold][bold][/bold]
2 数据结构的动态链表及其操作(插入结点、删除节点、向节点数据域录入数据,[bold]在链表中检索满足条件的节点(如总评成绩低于60的节点)并显示节点数据域的内容。[/bold]
3 [bold]能生成指定班指定课程的单科成绩表[/bold]

[align=center][bold]综合性、设计性和创新性实验报告基本要求[/bold][bold][/bold]

[/align][font=Times New Roman]一、
[/font]实验报告
1.完整的实验报告(实验项目名称、实验人员名单、实验日期、实验目的和要求、实验仪器设备、实验方案、实验步骤、实验结果、实验创新、实验讨论)
2.自主开发的程序软件技术工作报告还应包含需求分析、数据字典、系统结构图、模块功能简介,系统主要流程图,软件运行的测试情况,系统使用说明书及附录的源程序
二、 学生实验记录
[bold]软件运行界面图[/bold][bold][/bold]
[bold]软件运行数据输入图[/bold][bold][/bold]
[bold]软件运行的测试记录[/bold][bold][/bold]
[bold]软件运行结果图[/bold][bold][/bold]
[bold]
[/bold]

2007-11-28 12:52
快速回复:幫忙看看我錯在哪了,怎麽改
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.047033 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved