学生考试--成绩管理系统--源代码

学生课程成绩查询管理信息系统分析与设计--代码
#include
#include
#include
#include
#include
using namespace std;
class student
{ private:
char name[20]; //姓名
double cpro,english,math,sport,law,hbpro,computer;//课程
int order, number; //名次,学号
public:
student(){}
student(char n[20],int nu,double cc,double eng,double ma,double sp,double l,double hb,double com)
{strcpy(name,n);
number=nu;
cpro=cc; english=eng;math=ma;sport=sp;law=l;hbpro=hb;computer=com;
}
friend void main();
};



void main()
{
cout<<" 欢迎进入**学生成绩管理系统**!"<
cout<<" ******************************************"<cout<<" **** 学生成绩管理系统 ****"<cout<<" ******************************************"<cout<<" **************************"<cout<<" **0、输入数据 **"<cout<<" **1、增加数据 **"<cout<<" **2、修改数据 **"<cout<<" **3、按姓名查询 **"<cout<<" **4、按学号查询 **"<cout<<" **5、输出所有学生的成绩 **"<cout<<" **6、退出系统 **"<cout<<" **************************"<cout<<" 选择0-6数字进行操作"<
char p;char w;
student *s[50]; //指针对象,最多存50个学生数据
ofstream *file[50]; //负责对文件插入操作
int i=0;
int j=0;
int flag=0;
do //flag判断输入是否有效
{
cin>>p;
if((p>='0'&&p<='6'))
flag=1;
else
cout<<" 指令错误!请重新输入:"<}while(flag==0);
do{
switch(p) //接收功能选项
{
case '0': //输入数据
{
char c;
char name[20];int number;double cpro,english,math,sport,law,hbpro,computer;
do{
cout<<" 请输入姓名:";
cin>>name;
cout<cin>>number;
cout<<" 请输入C++成绩:";
cin>>cpro;
cout<cin>>english;
cout<cin>>math;
cout<cin>>sport;
cout<cin>>law;
cout<cin>>hbpro;
cout<cin>>computer;

cout<file[j]=new ofstream("D:\document",ios::ate);
*file[j]<<" 姓名 "<<<" 英语成绩 "<<

ter<j++;
s[i]=new student(name, number,cpro,english,math,sport,law,hbpro,computer);
i++;
cout<<" 数据输入成功,想继续输入吗(y/n):";
cin>>c;
cout<do
{
if(c!='y'&&c!='n')
{
cout<<" 指令错误!请重新输入!"<cin>>c;
}
else
flag=1;
}while(flag==0);
}while(c=='y');
break;
}

case '1': //增加数据
{
char name[20];
int number;double cpro,english,math,sport,law,hbpro,computer;
char c;
do
{
cout<<" 请输入您要增加的学生的姓名:";
cin>>name;
cout<cin>>number;
cout<cin>>cpro;
cout<cin>>english;
cout<cin>>math;
cout<cin>>sport;
cout<cin>>law;
cout<cin>>hbpro;
cout<cin>>computer;
cout<

file[j]=new ofstream("d:\document",ios::ate);
*file[j]<<" 姓名 "<j++;
s[i]=new student(name, number, cpro,english,math,sport,law,hbpro,computer);
i++;
cout<<" 数据输入成功,想继续数入吗(y/n):";
cin>>c;
cout<if(c!='y'&&c!='n')
{
cout<<" 指令错误!请重新输入!"<cin>>c;
}
}while(c=='y');
break;
}

case '2': //修改数据
{
char name[20];int nu;double cc,eng,ma,sp,l,hb,com;flag=0;
char c;
if(i==0)
{
cout<<" 管理系统中没有输入数据!"<}
do
{
cout<<" 请输入您要修改的学生的姓名:";
cin>>name;
cout<for(int h=0;h{
if(strcmp(name,s[h]->name)==0)
{
flag=1;
cout<<" 请输入新的学号:";
cin>>nu;
cout<cin>>cc;
cout<cin>>eng;
cout<cin>>ma;
cout<cin>>sp;
cout<cin>>l;
cout<cin>>hb;
cout<cin>>com;
cout<s[h]->cpro=cc;
s[h]->english=eng;
s[h]->math=ma;
s[h]->sport=sp;
s[h]->law=

l;
s[h]->hbpro=hb;
s[h]->computer=com;
s[h]->number=nu;
cout<<" 数据修改成功!"<}
}
if(flag==0)
{
cout<<" 您要修改的学生本来就不存在!请检查重新输入!"<}
cout<<" 想继续修改吗(y/n):";
cin>>c;
cout<if(c!='y'&&c!='n')
{
cout<<" 指令错误!请重新输入!"<cin>>c;
}
}while(c=='y');
break;
}




case '3': //按姓名查询
{
char n[20];int j=0;char c;
if(i==0)
{
cout<<" 管理系统中没有输入数据!"<}
do{
int flag=0;
cout<<" 请输入你要查询的学生姓名:";
cin>>n;
cout<for(int j=0;j{
if(strcmp(n,(*s[j]).name)==0)
{
flag=1;
cout<<" 您要查询的学生是:"<<(*s[j]).name<cout<<(*s[j]).name<<"的成绩是: "<<" C++: "<<(*s[j]).cpro<<" 英语: "<<(*s[j]).english<<" 数学:"<<(*s[j]).math<<" 体育:"<<(*s[j]).sport<<" 法律:"<<(*s[j]).law<<" C:"<<(*s[j]).hbpro<<" 数据库 "<<(*s[j]).computer<}
}
if(flag==0)
cout<<" 对不起!您要查询的学生不存在!"<cout<<" 您想继续查询吗?(y/n):";
cin>>c;
cout<if(c!='y'&&c!='n')
{
cout<<" 指令错误!请重新输入!"<cin>>c;
}
}
while(c=='y');
break;
}
case '4': //按学号查询
{
int n,j=0;char c;
if(i==0){

cout<<" 管理系统中没有输入数据!"<}
do{
int flag=0;
cout<<" 请输入你要查询的学生的学号:";
cin>>n;
cout<for(int j=0;j{
if(s[j]->number==n)
{
flag=1;
cout<<" 您要查询的学生是:"<<(*s[j]).name<cout<<(*s[j]).name<<"的成绩是: "<<" C++:"<<(*s[j]).cpro<<" 英语:"<<(*s[j]).english<<" 数学:"<<(*s[j]).math<<" 体育:"<<(*s[j]).sport<<" 法律:"<<(*s[j]).law<<" C:"<<(*s[j]).hbpro<<" 数据库 "<<(*s[j]).computer<}
}
if(flag==0)
cout<<" 对不起!您要查询的学生不存在!"<cout<<" 您想继续查询吗?(y/n):";
cin>>c;
cout<if(c!='y'&&c!='n')
{
cout<<" 指令错误!请重新输入!"<cin>>c;
}
}
while(c=='y');
break;
}
case '5': //输出
{
cout<<" 本系统所有学生数据如下:"<if(i==0)
cout<<" 管理系统中没有输入数据!"<cout<<" 姓名 学号 c++ 英语 数学 体育 网络基础 C语言 数据库 "<for(int k=0;k{
cout<name<number<<<(*s[k]).cpro<<<

(*s[k]).math<<<(*s[k]).law <}
break;
}
case'6'://退出
{exit(0); cout<<"Bye bye!"<}
cout<<" 您想继续进行其他操作吗?(y/n):";
int flag=0;
do
{
cin>>w;
cout<if(w!='y'&&w!='n')
cout<<" 指令错误!请重新输入!"<else
flag=1;
}while(flag==0);
if(w=='y')
cout<<" 请输入操作代码:0 输入数据"<cout<<" 1 增加数据"<cout<<" 2 修改数据"<cout<<" 3 按姓名查询"<cout<<" 4 按学号查找"<cout<<" 5 输出所有学生成绩"<cout<<" 6 退出系统"<cin>>p;
}while(w=='y');
}

相关文档
最新文档