1、#include#include#include#includevoid homepage(); /主界面void display(); /显示全部成绩void input(); /录入 插入void del(); /删除记录void sort(); /排序void waiting(); /等待界面void quit(); /退出界面struct student int num; char name15; float score3; float avg;int count=0; /当前学生个数int sort_type=0; /当前排序类型struct student stu10;void m
2、ain() int i,k=0; char username15,pwd6; system(color 3f); printf(nn); printf(tn); printf(t*n); printf(t*n); printf(t*n); printf(t* *n); printf(t* 欢迎使用学生成绩管理系统 *n); printf(t* *n); printf(t* *n); printf(t* xxxxxxxxxxx *n); printf(t* *n); printf(t* 2006.11.11 *n); printf(t* *n); printf(t*n); printf(t*n)
3、; printf(t*n); printf(tn); for(i=0;i3;i+) printf(n请输入用户名:); gets(username); printf(n请输入6位密码:); gets(pwd); if(strcmp(username,s1t1102)=0)&(strcmp(pwd,123456)=0) printf(n您已经成功登录n); k=1; for(i=0;i20;i+) printf(.); Sleep(100); system(cls); homepage(); break; else printf(n用户名或密码无效 请重新输入:n); continue; if(
4、k=0) printf(n连续输入错误3次 将退出程序n); Sleep(2000); quit();void homepage() char n; printf(nn); printf(tn); printf(t*n); printf(t* * *n); printf(t* 1.显示成绩 * 2.录入成绩 *n); printf(t* * *n); printf(t*n); printf(t* * *n); printf(t* 3.删除记录 * 4.排序 *n); printf(t* * *n); printf(t*n); printf(t* *n); printf(t* 0.退出程序 *n
5、); printf(t* *n); printf(t*n); printf(tn); while (n!=1)&(n!=2)&(n!=3)&(n!=4)&(n!=0) printf(n请选择:); fflush(stdin); scanf(%c,&n); switch(n) case 1: display(); break; case 2: if(count10) input(); else printf(记录数已满n); Sleep(2000); system(cls); homepage(); break; case 3: del(); break; case 4: sort(); cas
6、e 0: quit(); break; default: printf(n选项错误n); void display() int i; char c; system(cls); switch(sort_type) case 0: printf(tt未排序:nn); break; case 1: printf(tt按学号排序:nn); break; case 2: printf(tt按成绩1排序:nn); break; case 3: printf(tt按成绩2排序:nn); break; case 4: printf(tt按成绩3排序:nn); break; case 5: printf(tt按
7、平均成绩排序:nn); break; printf(t学号t姓名t成绩1t成绩2t成绩3t平均成绩n); for(i=0;icount;i+) printf(t%dt%st%5.2ft%5.2ft%5.2ft%5.2fn,stui.num,stui.name,stui.score0,stui.score1,stui.score2,stui.avg); printf(nn按任意键返回n); c=getch(); system(cls); homepage();void input() int i,numcheck; char c; system (cls); do printf(学号:n); s
8、canf(%d,&stucount.num); numcheck=1; if(stucount.num0) printf(请输入正整数:n); for(i=0;icount;i+) if(stucount.num=stui.num) numcheck=0; printf(学号重复,重新输入:n); while(!numcheck); printf(姓名:n); fflush(stdin); gets(stucount.name); for(i=0;i3;i+) printf(第%d门课成绩:n,i+1); scanf(%f,&stucount.scorei); stucount.avg=(st
9、ucount.score0+stucount.score1+stucount.score2)/3; printf(是否继续输入(y/n):n); do c=getchar(); if(c=y|c=Y) count+; if(count10) input(); else printf(记录数已满n); Sleep(2000); system(cls); homepage(); else if(c=n|c=N) count+; system(cls); homepage(); else; while(c!=y)&(c!=n)&(c!=Y)&(c!=N);void del() int i,j,del
10、_num,match=0; char c; system(cls); printf(请输入要删除的学生学号:n); scanf(%d,&del_num); waiting(); for(i=0;icount;i+) if(stui.num=del_num) match=1; for(j=i;jcount;j+) /* stuj.num=stuj+1.num; strcpy(stuj.name,stuj+1.name); stuj.score0=stuj+1.score0; stuj.score1=stuj+1.score1; stuj.score2=stuj+1.score2; stuj.av
11、g=stuj+1.avg; */ stuj=stuj+1; if(!match) printf(没有要找的学号.n); printf(是否继续删除?(y/n); fflush(stdin); do c=getchar(); if(c=y|c=Y) count-; del(); else if(c=n|c=N) count-; system(cls); homepage(); else; while(c!=y)&(c!=n);void sort() int i,j; int choice; struct student temp; system(cls); printf(tt请选择排序功能:n)
12、; printf(t1.按学号排序n); printf(t2.按成绩1排序n); printf(t3.按成绩2排序n); printf(t4.按成绩3排序n); printf(t5.按平均成绩排序n); do scanf(%d,&choice); while(choice!=1)&(choice!=2)&(choice!=3)&(choice!=4)&(choice!=5); switch(choice) case 1: for(i=0;icount-1;i+) for(j=0;jstuj+1.num) temp=stuj; stuj=stuj+1; stuj+1=temp; sort_typ
13、e=1; break; case 2: for(i=0;icount-1;i+) for(j=0;jcount-i-1;j+) if(stuj.score0stuj+1.score0) temp=stuj; stuj=stuj+1; stuj+1=temp; sort_type=2; break; case 3: for(i=0;icount-1;i+) for(j=0;jcount-i-1;j+) if(stuj.score1stuj+1.score1) temp=stuj; stuj=stuj+1; stuj+1=temp; sort_type=3; break; case 4: for(
14、i=0;icount-1;i+) for(j=0;jcount-i-1;j+) if(stuj.score2stuj+1.score2) temp=stuj; stuj=stuj+1; stuj+1=temp; sort_type=4; break; case 5: for(i=0;icount-1;i+) for(j=0;jcount-i-1;j+) if(stuj.avgstuj+1.avg) temp=stuj; stuj=stuj+1; stuj+1=temp; sort_type=5; break; system(cls); waiting(); homepage();void wa
15、iting() int i; printf(nt请稍侯.); for(i=0;i25;i+) switch(i%4) case 1:printf(b);break; case 2:printf(b-);break; case 3:printf(b/);break; case 0:printf(b|);break; Sleep(100); system(cls);void quit() system(cls); printf(nn); printf(tn); printf(t*n); printf(t* *n); printf(t* 谢谢使用本程序 *n); printf(t*n); printf(tnn);