<html>
<body>
<pre>
<h1>Build Log</h1>
<h3>
--------------------Configuration: 学生信息管理系统 - Win32 Debug--------------------
</h3>
<h3>Command Lines</h3>
Creating temporary file "C:\DOCUME~1\Calm_Kai\LOCALS~1\Temp\RSP6.tmp" with contents
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:yes /pdb:"Debug/学生信息管理系统.pdb" /debug /machine:I386 /out:"Debug/学生信息管理系统.exe" /pdbtype:sept
".\Debug\学生信息管理系统.obj"
]
Creating command line "link.exe @C:\DOCUME~1\Calm_Kai\LOCALS~1\Temp\RSP6.tmp"
<h3>Output Window</h3>
Linking...
<h3>Results</h3>
学生信息管理系统.exe - 0 error(s), 0 warning(s)
</pre>
</body>
</html>
#include<iostream>
#include<fstream>
#include<string>
#include <windows.h>
using namespace std;
class student //学生类
{
private:
char name[10]; //姓名
char code[10]; //学号
char classes[8]; //班级
char sex[5]; //性别
char college[10]; //学院
float score[5]; //0-3各科目成绩,4-总成绩
public:
student *link;
student(){link=NULL;}
student(char* n,char* co,char* clas,char* sx,char* college,float* a);
~student(){}
void show(student *p);
void allshow();
friend class operate;
};
student *first=NULL;
student *point=NULL;
student::student(char* n,char* co,char* clas,char* sx,char* clg,float* a)
{
strcpy(name,n);
strcpy(code,co);
strcpy(classes,clas);
strcpy(sex,sx);
strcpy(college,clg);
link=NULL;
score[4]=0;
for(int i=0;i<4;i++)
{
score[i]=a[i];
score[4]=score[4]+score[i];
}
}
void student::show(student *p)
{
cout<<endl;
cout<<"姓名 :"<<p->name<<"\t性别 :"<<p->sex<<"\t学号 :"<<p->code<<"\t班级 :"<<p->classes<<"\t学院 :"<<p->college<<endl;
cout<<"数据结构成绩:"<<p->score[0]<<"\t概率论成绩:"<<p->score[1]<<"\t电子电工成绩:"<<p->score[2]<<"\t英语成绩:"<<p->score[3]<<endl;
cout<<"总成绩:"<<p->score[4]<<endl;
cout<<endl;
}
void student::allshow()
{
student *p=NULL;
cout<<endl;
for(p=first;p;p=p->link)
{
cout<<"姓名 :"<<p->name<<"\t性别 :"<<p->sex<<"\t学号 :"<<p->code<<"\t班级 :"<<p->classes<<"\t学院 :"<<p->college<<endl;
cout<<"数据结构成绩:"<<p->score[0]<<"\t概率论成绩:"<<p->score[1]<<"\t电子电工成绩:"<<p->score[2]<<"\t英语成绩:"<<p->score[3]<<endl;
cout<<"总成绩:"<<p->score[4]<<endl;
cout<<endl;
}
}
class operate //操作类
{
public:
void add();
student* search();
void del();
void arrange();
void change();
void load();
void save();
void clear();
void show(student *p);
void allshow();
private:
bool judge(char *c);
bool judge(char *c,student *d);
student* search1();
student* search2();
void searchclass();
void sort(int i);
int part(int left,int right,int m,student **p);
void quick(int left,int right,int m,student **p);
};
bool operate::judge(char *c)
{
student *p;
for(p=first;p;p=p->link)if(!strcmp(p->code,c))return false;
return true;
}
bool operate::judge(char *c,student *d)
{
student *p;
for(p=first;p;p=p->link)
{
if(p==d)continue;
if(!strcmp(p->code,c))return false;
}
return true;
}
void operate::clear()
{
student *p;
if(first==NULL)return;
while(first!=point)
{
p=first;
first=p->link;
delete p;
}
first=NULL;
delete point;
point=first;
}
void operate::add()
{
char n[10]; //姓名
char co[10]; //学号
char clas[8]; //籍贯
char sx[5]; //政治面貌
char clg[10]; //来校时间
float a[4]; //成绩
student *p;
cout<<"\n** 新建 **\n"; //输入信息
cout<<"输入 姓名:"; cin>>n;
cout<<"输入 学号:"; cin>>co;
while(!judge(co)){cout<<"\n学号已存在,请重新输入";cin>>co;}
cout<<"输入 班级:"; cin>>clas;
cout<<"输入 性别:"; cin>>sx;
cout<<"输入 学院名称:"; cin>>clg;
cout<<"输入 数据结构 成绩:"; cin>>a[0];
while(a[0]<0||a[0]>100){cout<<"\n数据超范围,请重新输入";cin>>a[0];}
cout<<"输入 概率论 成绩:"; cin>>a[1];
while(a[1]<0||a[1]>100){cout<<"\n数据超范围,请重新输入";cin>>a[1];}
cout<<"输入 电子电工 成绩:"; cin>>a[2];
while(a[2]<0||a[2]>100){cout<<"\n数据超范围,请重新输入";cin>>a[2];}
cout<<"输入 英语 成绩:"; cin>>a[3];
while(a[3]<0||a[3]>100){cout<<"\n数据超范围,请重新输入";cin>>a[3];}
p= new student(n,co,clas,sx,clg,a); //创建新结点
if(first!=NULL){point->link=p;point=p;}
else
{
point=p;
first=point;
}
show(point);
}
void operate::change()
{
char n[10]; //姓名
char co[10]; //学号
char clas[8]; //籍贯
char sx[5]; //政治面貌
char clg[10]; //来校时间
float a[4]; //成绩
student *p;
p=search();
if(p==NULL){cout<<"未找到该名学生\n";return;}
cout<<"\n** 修改 **\n"; //输入信息
cout<<"输入 姓名:"; cin>>n;
cout<<"输入 学号:"; cin>>co;
while(!judge(co,p)){cout<<"\n学号已存在,请重新输入";cin>>co;}
cout<<"输入 班级:"; cin>>clas;
cout<<"输入 性别:"; cin>>sx;
cout<<"输入 学院名称:"; cin>>clg;
cout<<"输入 数据结构 成绩:"; cin>>a[0];
while(a[0]<0||a[0]>100){cout<<"\n数据超范围,请重新输入";cin>>a[0];}
cout<<"输入 概率论 成绩:"; cin>>a[1];
while(a[1]<0||a[1]>100){cout<<"\n数据超范围,请重新输入";cin>>a[1];}
cout<<"输入 电子电工 成绩:"; cin>>a[2];
while(a[2]<0||a[2]>100){cout<<"\n数据超范围,请重新输入";cin>>a[2];}
cout<<"输入 英语 成绩:"; cin>>a[3];
strcpy(p->name,n);
strcpy(p->code,co);
strcpy(p->classes,clas);
strcpy(p->sex,sx);
strcpy(p->college,clg);
p->score[4]=0;
for(int i=0;i<4;i++)
{
p->score[i]=a[i];
p->score[4]=p->score[4]+a[i];
}
show(p);
}
student* operate::search()
{
char i;
cout<<"请选择 1-学号查找 2-姓名查找 3-班级查找\n";
cout<<"请注意删除、修改等功能中,不能使用班级查找功能\t";
cin>>i;
switch(i)
{
case '1':return search1();
case '2':return search2();
default:searchclass();return NULL;
}
}
student* operate::search1()
{
char b[10];student *p;
cout<<"请输入学号 ";
cin>>b;
for(p=first;p;p=p->link)
{
if(!strcmp(p->code,b))
{
show(p);
return p;
}
}
cout<<"未查找到\n";return NULL;
}
student* operate::search2()
{
char b[5];student *p;int i=0;
cout<<"请输入姓名 ";cin>>b;
for(p=first;p;p=p->link)
{
if(!strcmp(p->name,b)){show(p);i++;}
}
if(i==0){cout<<"未查找到该学生";return NULL;}
else if(i==1){ return p;}
else
{
cout<<"以上是数据中符合条件,如果查找到请输入学号,未查到请输入no";
return search1();
}
}
void operate::searchclass()
{
char b[8];student *p;int i=0;
cout<<"请输入班级 ";cin>>b;
for(p=first;p;p=p->link)
{
if(!strcmp(p->classes,b)){show(p);i++;}
}
if(i==0)cout<<"未找到该班级"<<endl;
}
void operate::del()
{
student *p=NULL,*q;
p=search();
if(p!=NULL)
{
if(p==first){first=p->link;delete p;}
for(q=first;q;q=q->link)if(q->link==p){q->link=p->link;delete p;cout<<"已成功删除.\n";}
}
}
void operate::save()
{
ofstream savefile;
savefile.open("student.txt",ios::out);
student *p;
for(p=first;p;p=p->link)
{
savefile<<p->name<<"\t";
savefile<<p->code<<"\t";
savefile<<p->classes<<"\t";
savefile<<p->sex<<"\t";
savefile<<p->college<<"\t";
savefile<<p->score[0]<<"\t"<<p->score[1]<<"\t"<<p->score[2]<<"\t"<<p->score[3]<<"\t";
}
savefile.close();
cout<<"数据已完成保存"<<endl;
}
void operate::load()
{
char n[10]; //姓名
char co[10];