1.求C语言源代码 题目 学生成绩管理系统
2.学生信息管理系统源代码
求C语言源代码 题目 学生成绩管理系统
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc,自动自动 char *argv[])
{ #define UP
#define DOWN
#define INSERT
#define DEL
#define ENTER
#define KEY
#define KEY
#define KEY
#define KEY
#define KEY A
#define KEY B
#define KEY C
#define KEY D
#define KEY E
#define KEY F
#define KEY G
#define KEY H
#define KEY I
#define KEY K
#define KEY L
#define KEY M
#define KEY N
#define KEY O
#define KEY P
#define KEY Q
#define KEY R
#define KEY S
#define KEY T
#define KEY U
#define KEY V
#define KEY W
#define KEY X
#define KEY Y
#define KEY Z
#define ALT F2
#define ALT F6
#define CTRL 4
#define SHIFT 1
#define ESC 1
#define BACKSPACE
#define LEN sizeof(struct student)
/*菜单选项。下拉标志*/
int menu x yes=1;
int menu y yes=0;
int menu x=1;
int menu x old=0;
int menu y1=1,排名排名lldb源码 menu y3=1;
/*保存文件名*/
char filename[]="NONAME.dat";
/*开辟保存数据的空间*/
void *buf=0;
int left,top,right,bottom;
/*开辟保存数据的空间*/
struct student
{ long num;
char name[];
float h maths;
float english;
float c;
float sum;
int s sum;
struct student*next;
};
struct student*head=0,*p1,*p2;
int record n;
char key buf[];
long student number=0;
char student name[];
float student score=0;
/*读键扫描码*/
char get key(void)
{ AH=0; int (0X); return( AH); }
/*显示字符*/
void show char(char z)
{ AL=z; AH=0x0e; int (0x);}
/*测试是否有键输入*/
int key pressed(void)
{ AH=0x0b; int (0x); if( AL==0) return(0); else return(1);}
/*退出程序*/
voidquit(void)
{ void free data(void);void restore menu(void); free data();
restore menu(); window(1,1,,,0x0f);
cur show(); gotoxy(1,1); exit(1);
}
/*回到dos提示符*/
void os shell(void)
{ void mainmenu show(void);
window(1,1,,,0x0f);
cur show(); gotoxy(1,1); system("");
mainmenu show();
}
/*主窗口文字*/
void main menu 1(void)
{ int i,j; char*p;
char*mainmenu word[]={ "File ","Save ","Options ","About me"};
if(menu x!=menu x old||!menu y yes)
{ p=mainmenu word[0];
putstr(4,1,0x,p,);
for(i=0;i<;i++) if(*p++<='Z') putchar(i+4,1,*(p-1),0x);
p=mianmenu word[0];
if(menu x yes)
for(i=0;j=0;i<;i++)
{ it('A'<=*p&&*(p+1)=='')break;
putchar(i+4,1,*p,0x0f); }
p++; }
}
}
void main menu 2(void)
{ int i; int len; char *p;
char*mainmenu word[6]={ "F1-Help","F2-Save","F5-OS shell","F-Menu","Message"};
void main box(void); main box();
p=mainmenu word[0]; putstr(2,,0x,p,);
for(i=0;i<;i++) { if(*p=='F'||('0'<=*p&&*p<='9'))putchar(i+2,*p,0x); p++; }
p=mainmenu word[4]; putstr(,,0x,p,9); len=strlen(filename);
putchar(-len/2-1,2,'',0x);
for(p=filename,i=0;*p!=0;p++;i++) putchar(-len/2+i,2,*p,0x);
putchar(-len/2+len,2,'',0x);
}
/*主窗口线框*/
void main box(void)
{ int i;
for(i=1;i<=;I++) { putchar(i,2,,0x); putchar(i,,,0x);putchar(i,,,0x);}
for(i=1;i<=;i++) { putchar(1,i,,0x); putchar(,i,,0x); }
putchar(1,2,,0x); putchar(,2,,0x); putchar(1,,,0x);
putchar(,,,0x); putchar(1,,,0x); putchar(,,,0x);
}
/*显示主窗口菜单*/
voidmianmenu show (void)
{ textmode set(); cur hide();
window(1,1,,,0x1e);
window(1,1,,1,0x);
window(1,,,,0x);
main menu ; main menu ;
}
/*显示下拉菜单*/
void menu show (void)
{ int i;
char*submenu word[][5]={ { "New file F4","Open file F3","OS shell F5","Quit Alt-X"},
p"Input F6","Delete F8","Update F9","query F","Sort F"}};
switch(menu x)
{ case 1:
if(menu x!=menu x old)
{ menu x old=menu x; menu window(3,2,,8); menu box(3,2,,8,3,0);}
for(i=0;i<2;i++)
{ putstr(4,3+i,0x,submenu word[0][i],);
putchar(5,3+i,*(submenu word[0][i]+1),0x); }
for(i=3;i<5;i++) putstr(4,3+i,0x7-,submenu word[0][i-1],);
putchar(6,6,*(submenu word[0][2]+2),0x);
putchar(5,7,*(submenu word[0][3]+1),0x);
window(4,2+menu y1,,2+menu y1,0x0f);
if(menu y1<=2)
putstr(4,2+menu y1,0x0f,submenu word[0][menu y1-1],);
else
putstr(4,2+menu y1,0x0f,submenu word[0][menu y1-2],); break;
case 2:menu x old=menu x; menu window(,2,,8);}
for(i=0;i<5;i++)
{ putstr(,3+i,0x,submenu word[1][i],);
putchar(,3+i,*(submenu word[1][i]+1,0x); }
window(,2+menu y3,,2+menu y3,0x0f);
putstr(,2+menu y3,0x0f,submenu word[1][menu y3-1],); break;
case 4:menu x old=menu x; }
}
/*清空键盘缓冲*/
void clr buf(void){ key buf[1]=0;}
void free data(void)
{ struct student*pa,*pb;
if(head)
{ pb=pa=head;
do{ pb=pa; pa=pb->next; free(pb);}while(pa!=0);head=0; }
}
/*姓名处理*/
int string name(void)
{ int i,j;
if(key buf[1]==0) return(0);
for(i=2,j=0;i<=key buf[1]+1;i++;j++)
student name[j]='\0'; return(1);}
/*输入数据*/
voidinput(int flag)
{ int i; char*s1="NO. Name H maths English C\\C++ ";
char*s2=" | | | | ";
char*title="INPUT"; menu window(,,,); window(,,,,0x);
putstr(,,0x,title,7); putstr(,,0x,s1,);
if(head==0)
{ head=p1=p2=(struct student*)malloc(LEN);if(!head)memory error();
p1->next=0;
else{
for(p1=head,record n=0;p1!=0;record n++)
{ p2=p1; p1=p2->next; }
p1=(struct student*)malloc(LEN);
if(!p1)memory error();
p2->next=p1; }
while(1)
{ record n++; putstr(,,0x,s2,);
if(flag==1)
{ gotoxy(,); printf("Record%d",record n); }
do{ window(,,,,0x);
if(!getstring(,,))goto out ;
}while(!getstring number());
p1->num=student number;
do{ if(!getstring(,,)) goto out;
}while(!string name());
strcpy(pi->name,student name);
for(i=1;i<=3;i++)
{ do{ window(+(i-1)*8,,0x);
if(!getstring(+(i-1)*8,,5)) gotoout;
}while(!string score());
if(i==1)p1->h maths=student score;
if(i==2)pi->english=student score;
if(i==3)p1->c=student score; }
p1->sum=0.0; p1->s num=0;
if(flag==2){ record n--;goto out;}
p2=p1;
p1=(struct student*)malloc(LEN);
if(!p1)memory error();
p1->next=0; p2->next=p1; }
out: cur hide(); window(,,,,0x1e);
if(flag==1) { if(head==p1)head=0; free(p1); p2->next=0; info(1); record n--; }
menu x yes=1; main menu 1();
}
/*查看是否有该成绩*/
struct student* search(int flag)
{ struct student8pa,*pb; if(head==0)return(0); pb=pa=head;
if(flag==1)
{ if(head->num==student number) return(head-1);
do{ if(pa->num==student number) return(pb);
pb=pa; pa=pb->next;} while(pa!=0); }
return (0);
}
/*查询,删除,系统系统hermeseventbus 源码修改对话框*/
struct student*msg box(int which)
{ int flag; int key; char*p="<-A B->"; menu window(,源码源码fcrom源码,,); gotoxy(,);
printf("Number OR Name"); window(,,,,0x); gotoxy(,);
printf(" | "); gotoxy(,);
switch(which)
{ case 1:printf("Delete");break;
case 2:printf("Update");break;
case 3:printf("Query");break; }
do{ while(!key pressed())
now time();
key=get key(); if(key==KEY A) { flag=1;break;}
if(key==KEY B) { flag=2;break;} printf("\");
}while(1);
putstr(,,0x,p,7);
if(flag==1)
{ do{
gotoxy(,); printf(" | "):
if(!getstring(,,)) goto out;
}while(!string number());
window(,,,,0x1e); return(search(1)); }
else
{ do{ gotoxy(,); printf(" | ");
if(!getstring(,,)) goto out;
}while(!string name());
window(,,,,0x1e); return(0);}
/*删除记录*/
void delete(void)
{ struct student*pa,*pb; pb=msg box(1); if(pb==0)info(3);
else
{ if(pb==(head-1))
{ pb=head; if(pb->next==0) head=0;
else head=pb->next; }
else
{ if(pb->next->next==0) { pb->next=pa; } }
record n--; info(2); }}
/*删除记录*/
void update(void)
{ int i; struct student*p; i=record n; p=msg box(2;
if(p==0)info(3);
else
{ input(2);
if(i==record n)
{ if(p==(head-1)){
head->num=p1->num; strcpy(head->name,p1->name);
head->h maths=p1->h maths; head->english=p1->english;
head->c=p1->c; free(p1); p2->next=0; }
else { p->next->num=p1->num; strcpy(p->next->name,p1->name);
p->next->h maths=p1->h maths; p->next->english=p1->english;
p->next->c=p1->c; free(p1); p2->next=0; }
info(4); }
else { record n--;p2->next=0;free(p1);info(5);} }}
/*查询成绩*/
void query(void)
{ struct student*p,*pa,*pb; int key ,flag,i,j;
char*str="NO. Name H matns English C\\C++ Sum S NO.";
char*sm="NO. Name h maths English C\\C++ (who fails)";
menu window(,,,); gotoxy(,); printf("Find Fail");
putchar(,,'A',0xe4); putchar(,,'B',0xe4);
do{ if(!key pressed()) now time();
key=get key();
if(key==KEY A){ flag=1;break;}
if(key==KEY B){ flag=2;break;}
printf("\"); }while(1);
window(,,,,0x1e); if(flag==1)
{ p=msg box(3); if(p==0) info(3);
else{ window(6,5,,,0x0e); window(5,4,,,0x5e); window(6,5,,,0x0e);
putstr(,4,0x5a,str,); gotoxy(6,6);
if(p!=(head-1)){ pa=p->next;p=pa;}
else p=head;
printf("%d%s%8.1f%9.1f%9.1f%9.1f%6d\n",\
p->num,p->name,p->h maths,p->english,p->c,p->sum,p->s sum);
}}
if(flag==2)
{ window(6,5,,,0x0e);window(5,4,,,0x5e); window(6,5,,,0x0e);
putchar(,4,0x5a,sm,); if(head)
{ pa=head; j=0;
do{ j++; i=0; window(6,5,,,0x0e); gotoxy(,);
printf("Page%d",j);
do
{ if(pa->c<||pa->h maths<||pa->english<)
{ gotoxy(6,6+i); i++;
printf("%d%s%8.1f%9.1f%9.1f%9.1f%6d\n",\
p->num,p->name,p->h maths,p->english,p->c,p->sum,p->s sum);}
pb=pa; pa=pb->next; }while(i!=&&pa!=0);
while(!key pressed()) now time();
get key(); }while(pa!=0);
goto out;}}
while(!key pressed())
now time();get key();
out:window(5,4,,,0x1e);}
/*成绩排名*/
void sort(void)
{ int i,j,n,flag; struct student*pa=0,*pb=0;
struct student*p[],*pmin;
char*str="NO. Name H maths English C\\C++ Sum S NO.";
window(6,5,,,0x0e); window(5,4,,,0x5e); window(6,5,,,0x0e);
putstr(,4,0x5a,str,); window(,,,,0x5b);
if(head!=0)
{ i=0; pb=pa=head;
do
{ p[i]=pa; i++; pa->sum=pa->h maths+pa->english+pa->c;
pb=pa; pa=pb->next; }while(pa!=0);
for(n=record n-1,i=0;i<n;i++)
{ flag=0;
for(j=0;j<n-i;j++)
if(p[j]->sum<p[j+1]->sum)
{ pmin=p[j]; p[j]=p[j+1]; p[j+1]=pmin; flag=1; }
if(flag==0)break; }
head=pb=pa=p[0]; head->s sum=1;
if(record n>1)
for(i=1;i<record n;i++) { pa->s sum=i; pb=pa; pa=pb->next=p[i];}
p2=p1=p[record n-1]; p1->s sum=record n;
p1->next=0; pb=pa=head;
j=0;
do{
j++;i=0; window(6,5,,,0x0e); gotoxy(,); printf("Page%d",j);
do
{ gotoxy(6,6+i); i++;
printf("%d%s%8.1f%9.1f%9.1f%9.1f%6d\n",\
p->num,p->name,p->h maths,p->english,p->c,p->sum,p->s sum);}
pb=pa; pa=pb->next; }while(i!=&&pa!=0);
while(!key pressed()) now time();
get key(); }while(pa!=0);
goto out;}
while(!key pressed())
now time();get key();
out:window(5,4,,,0x1e);}
/*输入文件名*/
int input filename(int m)
{ char*p; int fp; menu window(,,,);
window(,,,,0x);
gotoxy(,); printf("File name");
if(!getstring(,,)) goto no;
if(key buf[1]==0) goto no;
p=key buf+2; key buf[key buf[1]+2]='\0';
if(fp=fopen(p,"rb+"))==0)
{ if(m==2) goto no; if(fp=fopen(p,"wb+"))==0 goto no; }
fclose(fp); strcpy(filename,p);
yes: window(,,,,0x1e);
return(1);
no: window(,,,,0x1e);
return(0);
}
/*新建文件*/
void new file(void)
{ int fp;
if(input filename(1)==0) info(9;
else
{ main menu 2(); free data(); fp=fopen(filename,"wb+"); fclose(fp); info(); }
}
/*打开文件*/
void open file(void)
{ struct student*pa,*pb; int fp;
if(input filename(2)==0)info(6);
else
{ free data(); head=pb=pa=(struct student*)malloc(LEN); fp=fopen(filename,"rb+";
fread(&pa->num,LEN,1,fp);}
info(8); fclose(fp); input(1); }}
/*保存文件*/
void save fiel(void)
{ struct student8pa,*pb; int fp;
if((fp=fopen(filename,"rb+"))==0) fp=fopen(filename,"wb+");
pb=pa=head;
if(fp!=0&&head!=0)
{ do{ fwrite(&pa->num,LEN,1,fp); pb=pa; pa=pb->next;}while(pa!=0);
fclose(fp); }
info(7);
}
void about me(void)
{ int i; char*title="About Me"; char*str[]={ " I'M A BIG.BIG WORLD. "};
menu window(,5,,); putstr(,5,0x,title,);
for(i=0;i<;i++)putstr(,6+i,0x,str[i],);
while(!key pressed()) now time();
get key(); window(,5,,,0x1e);
}
system("PAUSE");
return EXIT_SUCCESS;
}
学生信息管理系统源代码
void Sort(student *&head, char type,char maxOrMin)
{
/*参数说明:
type=='1' 按 语文 排列
type=='2' 按 数学 排列
type=='3' 按 英语 排列
type=='4' 按 总分 排列
type=='5' 按 平均分 排列
type=='6' 按 座号 排列
*/
student *pHead,*pH;
pHead=pH=head;
int len=GetLength(head);
float *array=new float[len];
int i;
int x=0;
float num=0;
while(head)
{
Count(head);
if(type=='1')
{
num=head->chinaNum;
}
else if(type=='2')
{
num=head->mathNum;
}
else if(type=='3')
{
num=head->englishNum;
}
else if(type=='4')
{
num=head->result;
}
else if(type=='5')
{
num=head->average;
}
else if(type=='6')
{
num=head->num;
}
array[x]=num;
x++;
head=head->next;
}
head=pHead;
if(maxOrMin=='1')
{
for( i=1; i<len; i++)
{
for(int j=0; j<len-i; j++)
{
if(array[j]<array[j+1])
{
float num;
num=array[j];
array[j]=array[j+1];
array[j+1]=num;
}
}
}
}
else
{
for( i=1; i<len; i++)
{
for(int j=0; j<len-i; j++)
{
if(array[j]>array[j+1])
{
float num;
num=array[j];
array[j]=array[j+1];
array[j+1]=num;
}
}
}
}
int pos=1;
for(i=0; i<len; i++)
{
head=pHead;
while(head)
{
if(type=='1')
{
num=head->chinaNum;
}
else if(type=='2')
{
num=head->mathNum;
}
else if(type=='3')
{
num=head->englishNum;
}
else if(type=='4')
{
num=int(head->result);
}
else if(type=='5')
{
num=int(head->average);
}
else if(type=='6')
{
num=int(head->num);
}
int n=0;
if(int(array[i])==int(num))
{
if(int(array[i])!=int(array[i+1]))
{
if(n==0)
{
n=pos;
}
head->pos=pos;
pos++;
}
else
{
head->pos=n;
}
}
head=head->next;
}
}
head=pH;
delete []array;
}
void Count(student *&head)
{
head->result=head->chinaNum+head->englishNum+head->mathNum;
head->average=head->result/3;
}
void DeleteAll(student* &head)
{
student *cp,*np;
cp=head;
while(cp)
{
np=cp->next;
delete cp;
cp=np;
}
head=NULL;
}
void ChaXun(string str,student *head)
{
Sort(head,'4','1');
cout<<"欢迎使用查询功能"<<endl<<endl;
cout<<"请输入你要按什么查询 1->一般查询 2->查找最多 3->查找最少"<<endl;
string s;
cin>>s;
while(s[0]!='1'&&s[0]!='2'&&s[0]!='3')
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>s;
}
if(s[0]=='1')
{
cout<<"按什么查询?"<<endl;
cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩 "
<<"5->英语成绩 6->总分 7->平均分 8->排名"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' && str[0]!='6' &&
str[0]!='7' && str[0]!='8' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
char findStr[];
cout<<"请输入要查找的关键字或关键数:"<<endl;
cin>>findStr;
switch(str[0])
{
case '1':
Find(head,findStr,'1');
break;
case '2':
Find(head,findStr,'2');
break;
case '3':
Find(head,findStr,'3');
break;
case '4':
Find(head,findStr,'4');
break;
case '5':
Find(head,findStr,'5');
break;
case '6':
Find(head,findStr,'6');
break;
case '7':
Find(head,findStr,'7');
break;
case '8':
Find(head,findStr,'8');
break;
}
}
else if(s[0]=='2')
{
cout<<"请输入要按什么查询?"<<endl;
cout<<"1->语文成绩 2->数学成绩 "
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;
string s;
cin>>s;
switch(s[0])
{
case '1':
FindMaxOrMin(head,'1','1');
break;
case '2':
FindMaxOrMin(head,'2','1');
break;
case '3':
FindMaxOrMin(head,'3','1');
break;
case '6':
FindMaxOrMin(head,'6','1');
break;
case '5':
FindMaxOrMin(head,'5','1');
break;
default:
FindMaxOrMin(head,'4','1');
break;
}
}
else if(s[0]=='3')
{
cout<<"请输入要按什么查询?"<<endl;
cout<<"1->语文成绩 2->数学成绩 "
<<"3->英语成绩 4->总分 5->平均分 6->排名"<<endl;
string s;
cin>>s;
switch(s[0])
{
case '1':
FindMaxOrMin(head,'1','2');
break;
case '2':
FindMaxOrMin(head,'2','2');
break;
case '3':
FindMaxOrMin(head,'3','2');
break;
case '6':
FindMaxOrMin(head,'6','2');
break;
case '5':
FindMaxOrMin(head,'5','2');
break;
default:
FindMaxOrMin(head,'4','2');
break;
}
}
}
void ZengJia(string str, student* &head)
{
student *pNew=new student;
cout<<"欢迎使用增加功能"<<endl<<endl;
cout<<"请输入新学生的名字 :"<<endl;
cin>>pNew->name;
cout<<"请输入新学生的座号 :"<<endl;
cin>>pNew->num;
cout<<"请输入他的语文分数 :"<<endl;
cin>>pNew->chinaNum;
cout<<"请输入他的数学分数"<<endl;
cin>>pNew->mathNum;
cout<<"请输入他的英语分数"<<endl;
cin>>pNew->englishNum;
cout<<"插入记录的 (1->最前面 2->最后面)"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2')
{
cout<<"你输入错误,请重新输入."<<endl;
cout<<"插入记录的 (1->最前面 2->最后面)"<<endl;
cin>>str;
}
if(str[0]=='1')
{
InsertFront(head,pNew);
}
else if(str[0]=='2')
{
InsertRear(head,pNew);
}
cout<<"新学生增加成功."<<endl;
}
void ShanChu(string str, student *&head)
{
char delStr[];
cout<<"欢迎使用删除功能"<<endl<<endl;
cout<<"1->查询删除 2->全部删除"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2')
{
cout<<"输入错误,请重新输入."<<endl;
cin>>str;
}
if(str[0]=='1')
{
cout<<"请输入要删除的关键字"<<endl;
cin>>delStr;
cout<<"1->删除第一条找到的记录 2->删除所有找到的记录"<<endl;
cin>>str;
while(str[0]!='1'&&str[0]!='2')
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
cout<<"你真的要删除吗? 1->删除 2->取消"<<endl;
string s;
cin>>s;
if(str[0]=='1')
{
if(str[0]=='1')
{
Delete(head,delStr,1);
}
else
{
Delete(head,delStr,2);
}
}
else
{
cout<<"你已经取消删除了."<<endl;
}
}
else
{
cout<<"你真的要删除全部数据吗?这样会使你的数据全部丢失哦."<<endl;
cout<<"1->全部删除 2->取消删除"<<endl;
cin>>str;
if(str[0]=='1')
{
DeleteAll(head);
}
else
{
cout<<"你已经取消删除了."<<endl;
}
}
}
void PaiMing(string str, student* head)
{
string s;
cout<<"欢迎使用排名功能"<<endl<<endl;
cout<<"排名选择: 1->升序 2->降序"<<endl;
cin>>s;
cout<<"请输入要按什么排名?"<<endl;
cout<<"1->语文成绩 2->数学成绩 3->英语成绩 "
<<"4->总分 5->平均分 6->座号"<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' && str[0]!='6' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
cout<<"姓名:"<<setw(8)<<"座号:"<<setw()
<<"语文分数:"<<setw() <<"数学分数:"
<<setw()<<"英语分数:"<<setw(8)<<"总分数:"
<<setw(8)<<"平均分:"<<setw(6)<<"名次:"<<endl<<endl;
if(s[0]=='2')
{
switch(str[0])
{
case '1':
Sort(head,'1','1');
break;
case '2':
Sort(head,'2','1');
break;
case '3':
Sort(head,'3','1');
break;
case '4':
Sort(head,'4','1');
break;
case '5':
Sort(head,'5','1');
break;
case '6':
Sort(head,'6','1');
break;
}
}
else
{
switch(str[0])
{
case '1':
Sort(head,'1','2');
break;
case '2':
Sort(head,'2','2');
break;
case '3':
Sort(head,'3','2');
break;
case '4':
Sort(head,'4','2');
break;
case '5':
Sort(head,'5','2');
break;
case '6':
Sort(head,'6','2');
break;
}
}
ShowList(head);
return ;
}
void XianShi(string str, student *head)
{
Sort(head,'4','1');
string s;
cout<<"欢迎使用显示功能"<<endl;
cout<<"1->显示全部记录 2->显示记录数目"<<endl;
cin>>s;
if(s[0]=='2')
{
cout<<"记录的数目是:"<<GetLength(head)<<endl;
}
else
{
ShowList(head);
}
}
void XuiGai(string str, student *&head)
{
string s;
student *std;
cout<<"欢迎使用修改功能"<<endl;
cout<<"请输入你要按什么查询"<<endl;
cout<<"1->姓名 2->座号 3->语文成绩 4->数学成绩 "
<<"5->英语成绩 "<<endl;
cin>>str;
while(str[0]!='1' && str[0]!='2' &&
str[0]!='3' && str[0]!='4' &&
str[0]!='5' )
{
cout<<"你输入错误,请重新输入."<<endl;
cin>>str;
}
char findStr[];
cout<<"请输入要查找的关键字或关键数:"<<endl;
cin>>findStr;
switch(str[0])
{
case '1':
std=Find(head,findStr,'1');
Reword(std);
break;
case '2':
std=Find(head,findStr,'2');
Reword(std);
break;
case '3':
std=Find(head,findStr,'3');
Reword(std);
break;
case '4':
std=Find(head,findStr,'4');
Reword(std);
break;
case '5':
std=Find(head,findStr,'5');
Reword(std);
break;
}
Write(head);
if(std!=NULL)
{
cout<<"修改成功."<<endl;
}
}
int Run()
{
bool isLoad=false;
student* head=NULL;
student *pNew=new student;
head=Read();
SetTitle(false);
if(head!=NULL)
{ Sort(head,'5','1');
Count(head);
}
string str;
SetTitle(false);
cout<<" 欢迎使用学生管理系统 "<<endl<<endl;
cout<<" 1->用户登陆 2->退出程序 "<<endl;
cin>>str;
if(str[0]=='2')
{
AboutMe();
return 0;
}
else
{
isLoad=Enter('1');
system("cls");
if(isLoad==true)
{
SetTitle(true);
cout<<" 恭喜,您输入的密码正确.可以对本系统的进行任何操作."<<endl;
}
else
{
cout<<" Sorry,您输入的密码错误.你不能修改本系统的任何内容."<<endl;
}
}
begin:
cout<<endl<<endl;
cout<<" 欢迎使用学生管理系统 "<<endl<<endl;
cout<<" 1->增加功能 2-查询功能"<<endl;
cout<<" 3->删除功能 4-排名功能"<<endl;
cout<<" 5->显示功能 6-修改功能"<<endl;
cout<<" 7->用户设置 8-退出程序"<<endl;
cout<<"请输入您的选择: "<<endl;
cin>>str;
while(str[0]!='8')
{
if(isLoad==true && head!=NULL)
{
cout<<endl<<endl;
if(str[0]=='1')
{
ZengJia(str, head);
Sort(head,'4','1');
Write(head);
}
else if(str[0]=='2')
{
ChaXun(str,head);
}
else if(str[0]=='3')
{
ShanChu(str,head);
Sort(head,'4','1');
Write(head);
}
else if(str[0]=='4')
{
PaiMing(str,head);
}
else if(str[0]=='5')
{
XianShi(str,head);
}
else if(str[0]=='6')
{
XuiGai(str,head);
Write(head);
}
else if(str[0]=='7')
{
cout<<"欢迎使用用户修改功能"<<endl;
isLoad=Enter('2');
}
else if(str[0]=='8')
{
AboutMe();
return 0;
}
else
{
cout<<"你输入错误,请重新输入."<<endl;
goto begin;
}
}
else if(isLoad==false && head!=NULL)
{
if(str[0]=='2')
{
ChaXun(str,head);
}
else if(str[0]=='4')
{
PaiMing(str,head);
}
else if(str[0]=='5')
{
XianShi(str,head);
}
else
{
cout<<"你不是管理员,不能进行此项功能."<<endl;
cout<<"你只能进行 查询功能 显示功能 排名功能"<<endl;
}
}
else if( head==NULL && isLoad==true)
{
cout<<"系统检查到你没有任何记录,不能进行任何操作,只能增加记录."<<endl;
ZengJia(str, head);
Write(head);
head=Read();
}
else if( head==NULL && isLoad==false)
{
cout<<"因为你没有登陆,系统又检查到你没有任何记录,你不能进行任何操作."<<endl;
}
cout<<endl<<endl;
cout<<"按任何键继续进行操作."<<endl;
getchar();
getchar();
system("cls");
goto begin;
}
AboutMe();
return 0;
}
void SetTitle(bool isLoad)
{
HWND hwnd=GetForegroundWindow();
if(isLoad==false)
{
SetWindowText(hwnd," 学生管理系统(没有登陆)");
}
else
{
SetWindowText(hwnd," 学生管理系统(已经登陆)");
}
system("color a");
}
void AboutMe()
{
char*pStr= " ┃ \n"
" ┃ \n"
" ┏━━━━┻━━━━┓ \n"
" ┃ 关于作者 ┃ \n"
" ┏━━━━┻━━━━━━━━━┻━━━━┓\n"
" ┃ ┃\n"
" ┃ Aauthor: