求C语言学生成绩管理系统程序一道,用链表实现。可查询,修改,登陆!
请各位朋友提供原代码!小女在此谢过!
void into(); void out(); void quit(); void insert(); void sort(); void delete(); void fromname(); void fromnum(); void pass(); void best(); void sars(); void fengm(); void load();
void WrtMnMenu(); void WrtSbMenu(); void SlctMenu(); void SlctMnMenu(); void SlctSbMenu(); int GetKey(); void SbFunGo(); void Screen(); void Wind(int ,int ,int, int ,int ,int ,int,int,int); void Quit(); int Mm=0; int Smm[4]; int SbNum[4]={3,3,2,2}; int SbWid[4]={10,10,10,10}; int SbX[4]={5,20,33,47}; int Key=0; char Buf[1000]; int x1=5,y1=3,x2=76,y2=23; char *Main[4]={"学生档案","档案修改","档案查找","成绩统计"}; char *Sub[4][6]={ {"输入档案", "输出档案", "退出"}, {"插入", "排序", "删除" }, {"由姓名", "由学号" }, {"及格人数", "优秀人数", "平均分" }}; main() {sars(); load(); fengm(); Screen(); WrtMnMenu(); WrtSbMenu(); SlctMenu(); Quit(); return(0);} void sars() { int gd=DETECT,gm,i,n; float t,x[6],y[6],a[5],b[5]; initgraph(&gd,&gm,"d:\\tc"); bar(45,49,50,440); setfillstyle(1,RED); bar(50,50,590,430); t=6.28/5;
/*大五角星*/ for(i=0;i<6;i++) { x[i]=140+45*cos(.1*3.14+i*t-3.14); y[i]=145+45*sin(.1*3.14+i*t-3.14); } for(i=0;i<5;i++) { a[i]=140+17*cos(.1*3.14+i*t+3.77); b[i]=145+17*sin(.1*3.14+i*t+3.77); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } setfillstyle(1,YELLOW); floodfill(140,145,YELLOW); /*小五角星1*/ for(i=0;i<6;i++) { x[i]=240+15*cos(.314+i*t-3.14-.8); y[i]=80+15*sin(.314+i*t-3.14-.8); } for(i=0;i<5;i++) { a[i]=240+6*cos(.314+i*t+3.77-.8); b[i]=80+6*sin(.314+i*t+3.77-.8); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(240,80,YELLOW); /*小五角星2*/ for(i=0;i<6;i++) { x[i]=270+15*cos(.314+i*t-3.14-.5); y[i]=120+15*sin(.314+i*t-3.14-.5); } for(i=0;i<5;i++) { a[i]=270+6*cos(.314+i*t+3.77-.5); b[i]=120+6*sin(.314+i*t+3.77-.5); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(270,120,YELLOW); /*小五角星3*/ for(i=0;i<6;i++) { x[i]=270+15*cos(.314+i*t-3.14+.05); y[i]=170+15*sin(.314+i*t-3.14+.05); } for(i=0;i<5;i++) { a[i]=270+6*cos(.314+i*t+3.77+.05); b[i]=170+6*sin(.314+i*t+3.77+.05); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(270,170,YELLOW); /*小五角星4*/ for(i=0;i<6;i++) { x[i]=240+15*cos(.314+i*t-3.14+.2); y[i]=210+15*sin(.314+i*t-3.14+.2); } for(i=0;i<5;i++) { a[i]=240+6*cos(.314+i*t+3.77+.2); b[i]=210+6*sin(.314+i*t+3.77+.2); } setcolor(YELLOW); for(i=0;i<5;i++) { line(x[i],y[i],a[i],b[i]); line(a[i],b[i],x[i+1],y[i+1]); } floodfill(240,210,YELLOW); settextstyle(0, 0, 3); outtextxy( 74,432,"我们中国人不怕SARS!"); getch(); };
void load() {int driver=DETECT,mode; initgraph(&driver,&mode,"");
setbkcolor(0); settextstyle(0,0,0); outtextxy(264,300,"Loading......"); setfillstyle(SOLID_FILL,GREEN); bar(184,320,449,328); sleep(1); setfillstyle(SOLID_FILL,LIGHTGREEN); bar(184,320,214,328); sleep(1); bar(214,320,261,328); sleep(1); bar(261,320,308,328); sleep(1); bar(308,320,355,328); sleep(1); bar(355,320,402,328); sleep(1); bar(402,320,449,328); sleep(1); closegraph(); } void fengm() {int gdrive=DETECT,gmode; initgraph(&gdrive,&gmode,""); setbkcolor(0);
setfillstyle(SOLID_FILL,LIGHTBLUE); bar(20,15,620,295);
setfillstyle(SOLID_FILL,BLACK); bar(100,70,580,250);
setfillstyle(SOLID_FILL,LIGHTGRAY); bar(80,55,560,235);
setfillstyle(SOLID_FILL,BLACK); bar(160,110,520,190);
setfillstyle(SOLID_FILL,RED); bar(140,95,500,175);
rectangle(23,18,617,292); rectangle(83,58,557,232); settextstyle(0,0,2); outtextxy(190,125,"学生信息管理系统"); /*一个汉字8*8点阵?*/ settextstyle(0,0,1); outtextxy(320,204,"摆渡人工作组制作"); outtextxy(410,264,"2003年5月"); line(0,450,640,450); settextstyle(0,0,1); outtextxy(260,456,"按任意键继续......"); getch(); closegraph(); }
void WrtMnMenu() /*写主菜单*/ { int i; window(1,1,80,25); textattr(0x3e); for(i=0;i<4;i++) { gotoxy(SbX[i],1); cputs(Main[i]); } gotoxy(SbX[Mm],1); textattr(0x4e); cputs(Main[Mm]); if(Key==ESC||Key==ALT_X) exit(0);} void WrtSbMenu() /*写下拉式菜单*/ { int i; gettext(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm]+1,SbNum[Mm]+4,Buf); Wind(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm],SbNum[Mm]+3,1,1,3,15,1); textattr(0x3f); for(i=0;i<SbNum[Mm];i++) { gotoxy(2,1+i); cputs(Sub[Mm][i]);} textattr(0x1e); gotoxy(2,Smm[Mm]+1); cputs(Sub[Mm][Smm[Mm]]); } void SlctMenu() /*选择菜单*/ { while (Key!=ALT_X&&Key!=ESC) { Key=GetKey(); if(Key==LEFT||Key==RIGHT) SlctMnMenu(); if(Key==UPPER||Key==DOWN) SlctSbMenu(); if(Key==ENTER) SbFunGo();} return;} void SlctMnMenu() /*选择主菜单*/ {window(1,1,80,25); textattr(0x3e); gotoxy(SbX[Mm],1); cputs(Main[Mm]); textattr(0x31); puttext(SbX[Mm]-2,2,SbX[Mm]+SbWid[Mm]+1,SbNum[Mm]+4,Buf); if(Key==LEFT) Mm=Mm==0?3:Mm-1; if(Key==RIGHT) Mm=Mm==3?0:Mm+1; textattr(0x4e); gotoxy(SbX[Mm],1); cputs(Main[Mm]); WrtSbMenu();} void SlctSbMenu() /*选择下拉式菜单*/ {textattr(0x3f); gotoxy(2,1+Smm[Mm]); cputs(Sub[Mm][Smm[Mm]]); if(Key==UPPER) Smm[Mm]=Smm[Mm]==0?SbNum[Mm]-1:Smm[Mm-1]; if(Key==DOWN) Smm[Mm]=Smm[Mm]==SbNum[Mm]-1?0:Smm[Mm]+1; textattr(0x1e); gotoxy(2,Smm[Mm]+1); cputs(Sub[Mm][Smm[Mm]]);}
int GetKey() {int Ch,Low,Hig; Ch=bioskey(0); Low=Ch&0x00ff; Hig=(Ch&0xff00)>>8; return(Low==0?Hig+256:Low);} void SbFunGo() /*执行菜单命令*/ { void *buffer; /*buffer=(void *)calloc(100);*/ switch(Mm) {case 0: switch(Smm[0]) /*输入档案*/ { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); into(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: /*输出档案*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); out(); puttext(1,1,80,25,buffer); free(buffer); break; case 2: /*退出*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); quit(); puttext(1,1,80,25,buffer); free(buffer); break; } break; case 1: /*插入档案*/ switch(Smm[1]) { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); insert(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: /*排序*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); sort(); puttext(1,1,80,25,buffer); free(buffer); break; case 2: /*删除档案*/ delete(); buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); puttext(1,1,80,25,buffer); free(buffer); break; } break; case 2: /*按名字查询*/ switch(Smm[2]) { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); fromname(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: /*按学号查询*/ buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); fromnum(); puttext(1,1,80,25,buffer); free(buffer); break; } break;
case 3: switch(Smm[3]) { case 0: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); pass(); puttext(1,1,80,25,buffer); free(buffer); break; case 1: buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); best(); puttext(1,1,80,25,buffer); free(buffer);break; } break; } }
void out() { FILE *fp; char key; int i,j,n; void *buffer; buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); cprintf("can't open!"); exit(0);}
for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0&&Key!=ESC;i++) { gotoxy(2,1); cprintf("假如想中断,按键B");gotoxy(2,2); cprintf("姓名:%s",stu[i].name);gotoxy(2,3); cprintf("学生信息:");gotoxy(2,4); cprintf("学号:%d",stu[i].num);gotoxy(2,5); cprintf("班级:%s",stu[i].class);gotoxy(2,6); cprintf("性别:%s",stu[i].sex);gotoxy(2,7); cprintf("出生日期");gotoxy(15,7); cprintf("年:%d",stu[i].birth.year);gotoxy(23,7); cprintf("月:%d",stu[i].birth.month);gotoxy(31,7); cprintf("日:%d",stu[i].birth.date);gotoxy(2,8); cprintf("政治面貌:%s",stu[i].pol);gotoxy(2,9); cprintf("家庭住址:%s",stu[i].addr);gotoxy(2,10); cprintf("输出期末成绩:");gotoxy(2,11); cprintf("高等数学:%d",stu[i].score.score1[0]);gotoxy(15,11); cprintf("英语:%d",stu[i].score.score1[1]);gotoxy(25,11); cprintf("C语言:%d",stu[i].score.score1[2]);gotoxy(35,11); cprintf("大学物理:%d",stu[i].score.score1[3]);gotoxy(48,11); cprintf("马哲:%d",stu[i].score.score1[4]);gotoxy(58,11); cprintf("平均分:%d",(stu[i].score.score1[0]+stu[i].score.score1[1]+ stu[i].score.score1[2]+stu[i].score.score1[3]+stu[i].score.score1[4])/5); cprintf("按任意键继续!"); key=getch(); if(key=='B'||key=='b') { clrscr(); puttext(1,1,80,25,buffer); free(buffer);getch(); return; } Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); } fclose(fp); return;} void sort() /* 排序 */ { FILE *fp; void *buffer; int i,j,n,sum1[ALL],p[ALL]; char key; buffer=(void *)malloc(2*80*25); gettext(1,1,80,25,buffer); Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); gotoxy(2,1); cprintf("由分数排名:"); gotoxy(30,1); cprintf("按任意键开始!"); getch(); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,5); cprintf("没有记录!"); getch(); exit(0);} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++) {sum1[i]=stu[i].score.score1[0]+stu[i].score.score1[1]+stu[i].score.score1[2]+ stu[i].score.score1[3]+stu[i].score.score1[4]; stu[i].score.ave1=sum1[i]/5; p[i]=stu[i].score.ave1; n=i; fclose(fp); /*sort average*/ for(i=0;i<n;i++) for(j=i+1;j<n;j++) if(p[i]<p[j]) /*平均分比较*/ { MID=stu[i]; stu[i]=stu[j]; stu[j]=MID;} fp=fopen("a:\\stu.new","a+"); for(i=0;i<n;i++) fwrite(&stu[i],sizeof(struct student),1,fp); fclose(fp); /*put out*/ gotoxy(2,2); cprintf("结果是:"); fp=fopen("a:\\stu.new","r"); for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0&&Key!=ESC;i++) { gotoxy(2,3); cprintf("想中断,按键 B"); gotoxy(2,4); cprintf("第%d名是:",i+1);gotoxy(2,5); cprintf("%s",stu[i].name);gotoxy(2,6); cprintf("期末成绩:");gotoxy(2,7); cprintf("高等数学:%d",stu[i].score.score1[0]);gotoxy(15,7); cprintf("英语:%d",stu[i].score.score1[1]);gotoxy(25,7); cprintf("C语言:%d",stu[i].score.score1[2]);gotoxy(35,7); cprintf("大学物理:%d",stu[i].score.score1[3]);gotoxy(48,7); cprintf("马哲:%d",stu[i].score.score1[4]);gotoxy(58,7); cprintf("平均分:%d",(stu[i].score.score1[0]+stu[i].score.score1[1]+ stu[i].score.score1[2]+stu[i].score.score1[3]+stu[i].score.score1[4])/5); printf("按任意键继续"); key=getch(); if(key=='B'||key=='b') { clrscr(); puttext(1,1,80,25,buffer); free(buffer);getch(); return;} Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); } fclose(fp); return;} } void quit() { char *log[]={"想退出?,YES OR NO?", "按键Y/N"}; char key; Wind(30,10,60,20,2,0,1,15,1); textbackground(BLUE); do{textcolor(WHITE); gotoxy(1,3);cprintf("%s",log[0]); textcolor(WHITE); gotoxy(4,5);cprintf("%s",log[1]); gotoxy(21,5); key=getch(); if(key=='y'||key=='Y') {window(1,1,80,25);clrscr();exit(0);} else if(key=='n'||key=='N') break;} while(1); window(1,1,80,25); } void delete() /*删除档案*/ { FILE *fp; void *buf; int i,j,logic,del,n; char ch,name[10]; window(1,1,80,25); buf=(void *)malloc(80*2*25); gettext(1,1,80,25,buf); Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); /*将文本从存储区考备到屏幕*/ cprintf("can't open!"); getch();puttext(1,1,80,25,buf);free(buf);return;} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0&&Key!=ESC;i++); n=i; fclose(fp); gotoxy(2,1); cprintf("输入你想删除学生的姓名:"); scanf("%s",name); getch(); for(i=0,logic=1;i<n&&logic;i++) {if(strcmp(name,stu[i].name)==0) { del=i; logic=0;} } if(!logic) n--; else { gotoxy(2,4);cprintf("不能找到,按键返回!"); getch();puttext(1,1,80,25,buf);free(buf);return;}
fp=fopen("a:\\stu.new","w"); for(i=0;i<del;i++) fwrite(&stu[i],sizeof(struct student),1,fp); for(i=del+1;i<n;i++) fwrite(&stu[i],sizeof(struct student),1,fp); fclose(fp); gotoxy(2,5); cprintf("删除成功!"); getch(); puttext(1,1,80,25,buf);free(buf); return; } void pass() /*及格统计*/ { FILE *fp; int i,n,sum1[ALL],m1=0; char key; Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); cprintf("file can't open"); getch(); exit(0);} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++); n=i; fclose(fp); for(i=0;i<n;i++) { if((stu[i].score.score1[0]>=60)&&(stu[i].score.score1[1]>=60) &&(stu[i].score.score1[2]>=60)&&(stu[i].score.score1[3]>=60) &&(stu[i].score.score1[4]>=60)) m1++; } gotoxy(2,6); cprintf("及格人数是(期末):%d",m1); getch(); clrscr(); return;} /*优秀统计*/ void best() { FILE *fp; int i,n,sum1[ALL]; int t1=0; char key; Wind(1,2,80,23,2,0,1,15,1); textbackground(BLUE); if((fp=fopen("a:\\stu.new","r"))==NULL) { gotoxy(2,1); cprintf("file can't open"); getch(); exit(0);} for(i=0;fread(&stu[i],sizeof(struct student),1,fp)!=0;i++); n=i; fclose(fp); for(i=0;i<n;i++) {sum1[i]=stu[i].score.score1[0]+stu[i].score.score1[1]+stu[i].score.score1[2]+ stu[i].score.score1[3]+stu[i].score.score1[4]; stu[i].score.ave1=sum1[i]/5; } for(i=0;i<n;i++) { if((stu[i].score.score1[0]>=60)&&(stu[i].score.score1[1]>=60) &&(stu[i].score.score1[2]>=60)&&(stu[i].score.score1[3]>=60) &&(stu[i].score.score1[4]>=60)&&(stu[i].score.ave1>=80)) t1++;} gotoxy(2,6); cprintf("优秀人数是(期末):%d",t1); getch(); clrscr(); return;}