#define RECORD record.txt #define X1 6 #define X2 2 #include <stdio.h> #include <stdlib.h> #include <string.h> #include <graphics.h> #include <ctype.h> #include <bios.h> /*#include "class/CARTOON.C"*/ /*definition struct*/ struct { char name[10]; char sex; int studID; int classID; int english; int math; int computer; int recycle; int average; int total; int sort; }stud,temp2;
void cartoon(void) { float x,x1=0; char ch; int driver,i,mode,y=0; void base(void); void clr(int x,int y); void w(int x,int y); void e(int x,int y); void l(int x,int y); void c(int x,int y); void o(int x,int y); void m(int x,int y); printf("Do you want play the face?Y/N"); ch=getchar();getchar(); if(ch=='N'||ch=='n')return; driver=VGA;mode=VGAHI; initgraph(&driver,&mode,""); x=620; for(i=0;i<=200;i++) { setcolor(0);line(0,80,640,80);line(0,420,640,420); setcolor(15);line(640-x1,80,640,80);line(0,420,x1+=4.1,420); delay(1000); } y=81; for(i=0;i<20;i++) { setcolor(0);line(0,y,640,y);y+=2; setcolor(15);line(0,y,640,y); delay(3000); }
settextstyle(1,0,3);
setfillstyle(SOLID_FILL,0); clr(189,94); clr(230,94); clr(300,94); clr(380,94); delay(5000); setcolor(7); outtextxy(181,91,"My C Language Designs"); setcolor(15); outtextxy(180,90,"My C Language Designs"); setcolor(7); delay(10000); outtextxy(182,92,"My C Language Designs"); setcolor(7); outtextxy(181,91,"My C Language Designs"); setcolor(15); outtextxy(180,90,"My C Language Designs"); delay(10000); settextstyle(1,0,4); setfillstyle(SOLID_FILL,0); for(i=0;i<100;i+=3) { bar(1,1,640,77); outtextxy(71,i*0.4,"Student Scores Manage System"); delay(200000); } for(i=0;i<301;i+=4) { line(50,121,50,121+i);line(590,121,590,121+i); delay(2000); } settextstyle(1,0,4); for(i=0;i<170;i+=2) { line(50,150,50+i,150);line(590,150,590-i,150); delay(2000); } x=190; y=130; i=0; while(i<9) { switch(i++) { case 1:w(x+20*i,y);break; case 2:e(x+21*i,y);break; case 3:l(x+20*i,y);break; case 4:l(x+20*i,y);break; case 5:c(x+20*i,y);break; case 6:o(x+20*i,y);break; case 7:m(x+20*i,y);break; case 8:e(x+22*i,y);break; } } delay(20000); circle(570,170,10); delay(20000); circle(480,250,40); delay(20000); circle(320,280,80); delay(20000); circle(150,330,40); delay(20000); circle(70,400,10); settextstyle(1,0,4); outtextxy(70,170,"Design"); settextstyle(1,0,7); outtextxy(283,240,"By"); settextstyle(1,0,4); outtextxy(430,370,"GongTao"); settextstyle(1,0,3); outtextxy(150,430,"HuNan Agracutural University"); getch(); setfillstyle(LINE_FILL,1); for(i=480;i>0;i-=25) { bar(1,1,640,480-i); delay(2000); } setfillstyle(SOLID_FILL,1); for(i=0;i<480;i+=25) { bar(1,479-i,649,479); delay(2000); }
return; }
void base(void) { setcolor(15);line(0,80,640,80);line(0,420,640,420);line(0,121,640,121); }
void clr(int x,int y) {int r=300; static i=0; void base(void); i++; for(r=300;r>0;r-=6) { circle(x,y,r); delay(2000); setcolor(0); circle(x,y,r); base(); setcolor(15); switch(i) { case 2: outtextxy(180,90,"My"); break; case 3: outtextxy(180,90,"My C ");break; case 4: outtextxy(180,90,"My C Language");break; } } switch(i) { case 1: outtextxy(180,90,"My"); break; case 2: outtextxy(180,90,"My C ");break; case 3: outtextxy(180,90,"My C Language");break; case 4: outtextxy(180,90,"My C Language Designs");break; } }
void w(int x,int y) { outtextxy(x,y,"W"); delay(2000); } void e(int x,int y) { outtextxy(x,y,"e"); delay(2000); }
void l(int x,int y) { outtextxy(x,y,"l"); delay(2000); } void c(int x,int y) { outtextxy(x,y,"c"); delay(2000); } void o(int x,int y) { outtextxy(x,y,"o"); delay(2000); } void m(int x,int y) { outtextxy(x,y,"m"); delay(2000); }
main() { int go,isend; void add(void); void list(void); int face(void); void del(void); void modify(void); void search(void); void sort(void); void insert(void); void recovery(void); void statistics(void); void recycle(void); void cartoon(void); void realdel(void); cartoon(); while(1) { go=face(); switch(go) { case 1: add();break; case 2: list();break; case 3: del();break; case 4: modify();break; case 5: search();break; case 6: sort();break; case 7: insert();break; case 8: recovery();break; case 9: statistics();break; case 10:recycle();break; case 11:realdel();break; case 0:exit(0);break; } } }
/* add a new record*/ void add(void) {int Y1=3; char numstr[20],ch; FILE *fp; cleardevice(); if((fp=fopen("RECORD","ab"))==NULL) { printf("Cant't open file.");getch();exit(0);} gotoxy(X1,Y1); printf("Name"); gotoxy(X1+9,Y1); printf("Sex"); gotoxy(X1+(2*9),Y1); printf("StudID"); gotoxy(X1+(3*9),Y1); printf("ClassID"); gotoxy(X1+(4*9),Y1); printf("English"); gotoxy(X1+(5*9),Y1); printf("Math"); gotoxy(X1+(6*9),Y1); printf("Computer"); gotoxy(X1,++Y1); do{ gotoxy(0,Y1);clreol(); gotoxy(X1,Y1);/*return start position*/printf("\b%c",16); gets(stud.name);gotoxy(X1+9,Y1);printf("\b%c",16); stud.sex=getchar();getchar();gotoxy(X1+(2*9),Y1);printf("\b%c",16); gets(numstr);stud.studID=atoi(numstr);gotoxy(X1+(3*9),Y1);printf("\b%c",16); gets(numstr);stud.classID=atoi(numstr);gotoxy(X1+(4*9),Y1);printf("\b%c",16); gets(numstr);stud.english=atoi(numstr);gotoxy(X1+(5*9),Y1);printf("\b%c",16); gets(numstr);stud.math=atoi(numstr);gotoxy(X1+(6*9),Y1);printf("\b%c",16); gets(numstr);stud.computer=atoi(numstr);gotoxy(X1,Y1+1); stud.recycle=0;stud.sort=0; stud.total=stud.english+stud.computer+stud.math; stud.average=(stud.total)/3; fwrite(&stud,sizeof(stud),1,fp); printf("Add again?(y/n)"); ch=getchar();getchar(); gotoxy(X1,++Y1); }while(ch=='y' || ch=='Y'); fclose(fp); return; } /*end add*/
/*list all record*/ void list(void) { int Y1=3,i=0,sum=0,once=1,i2=0; FILE *fp; cleardevice(); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} while(fread(&stud,sizeof(stud),1,fp)) sum++; rewind(fp); if(sum==0) {printf("\nNo record in file.Pass any key return to Menu..");getch();return;} while(fread(&stud,sizeof(stud),1,fp)==1) { if(once==1) {Y1=2; clrscr(); gotoxy(X2,Y1); printf("Name"); gotoxy(X2+9,Y1); printf("Sex"); gotoxy(X2+(2*9),Y1); printf("StudID"); gotoxy(X2+(3*9),Y1); printf("ClassID"); gotoxy(X2+(4*9),Y1); printf("English"); gotoxy(X2+(5*9),Y1); printf("Math"); gotoxy(X2+(6*9),Y1); printf("Computer"); gotoxy(X2+(7*9),Y1); printf("Aver"); gotoxy(X2+(8*9),Y1++); printf("Total"); once=0; } if(!stud.recycle) { gotoxy(X2,Y1); printf("%s",stud.name);gotoxy(X2+(1*9),Y1); printf("%c",stud.sex);gotoxy(X2+(2*9),Y1); printf("%d",stud.studID);gotoxy(X2+(3*9),Y1); printf("%d",stud.classID);gotoxy(X2+(4*9),Y1); printf("%d",stud.english);gotoxy(X2+(5*9),Y1); printf("%d",stud.math);gotoxy(X2+(6*9),Y1); printf("%d",stud.computer);gotoxy(X2+(7*9),Y1); printf("%d",stud.average);gotoxy(X2+(8*9),Y1); printf("%d",stud.total);gotoxy(X2,++Y1);++i2; } if(++i==sum) {printf("\nPress any key return to Menu.....");getch();} if(sum>20&&i2!=0) {if((i2%20)==0){printf("\nPress any key to continue.....");getch();once=1;}} } fclose(fp); return; } /*end list*/
/*Delete record start*/ void del(void) { int go,Y1=3,once=0,sum=0; char numstr[20],yn='n'; FILE *fp,*temp; cleardevice(); temp=fopen("temp.txt","wb"); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} printf("Choose the StudID:"); gets(numstr);go=atoi(numstr);
while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle&&stud.studID==go) {sum++; if(++once==1) { gotoxy(X2,Y1); printf("Name"); gotoxy(X2+9,Y1); printf("Sex"); gotoxy(X2+(2*9),Y1); printf("StudID"); gotoxy(X2+(3*9),Y1); printf("ClassID"); gotoxy(X2+(4*9),Y1); printf("English"); gotoxy(X2+(5*9),Y1); printf("Math"); gotoxy(X2+(6*9),Y1); printf("Computer"); gotoxy(X2+(7*9),Y1); printf("Total"); gotoxy(X2+(8*9),Y1++); printf("Aver"); } gotoxy(X2,Y1);clreol(); printf("%s",stud.name);gotoxy(X2+(1*9),Y1); printf("%c",stud.sex);gotoxy(X2+(2*9),Y1); printf("%d",stud.studID);gotoxy(X2+(3*9),Y1); printf("%d",stud.classID);gotoxy(X2+(4*9),Y1); printf("%d",stud.english);gotoxy(X2+(5*9),Y1); printf("%d",stud.math);gotoxy(X2+(6*9),Y1); printf("%d",stud.computer);gotoxy(X2+(7*9),Y1); printf("%d",stud.average);gotoxy(X2+(8*9),Y1); printf("%d",stud.total);gotoxy(X2,++Y1); printf("Do you want to delete this record?y/n");yn=getchar();getchar(); if(yn=='n'||yn=='N'){fwrite(&stud,sizeof(stud),1,temp);yn='s';} else{stud.recycle=1;fwrite(&stud,sizeof(stud),1,temp);yn='s';} } if(yn!='s') {fwrite(&stud,sizeof(stud),1,temp);yn='';} yn=''; } if(!sum) {printf("No record! Press any key return to Menu...");fclose(fp); fclose(temp); remove("RECORD"); rename("temp.txt","RECORD");getch(); return; } fclose(fp); fclose(temp); remove("RECORD"); rename("temp.txt","RECORD"); return; } /*Delete record end*/
/*Modify start*/ void modify(void) { int go,Y1=3,once=0,sum=0; char numstr[20],yn='n'; FILE *fp,*temp; temp=fopen("temp.txt","wb"); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} cleardevice(); printf("Choose the StudID:"); scanf("%d",&go);getchar(); while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle&&stud.studID==go) { sum++; if(++once==1) { Y1=2; gotoxy(X1,Y1); printf("Name"); gotoxy(X1+9,Y1); printf("Sex"); gotoxy(X1+(2*9),Y1); printf("StudID"); gotoxy(X1+(3*9),Y1); printf("ClassID"); gotoxy(X1+(4*9),Y1); printf("English"); gotoxy(X1+(5*9),Y1); printf("Math"); gotoxy(X1+(6*9),Y1); printf("Computer"); gotoxy(X1,++Y1); } gotoxy(X1,Y1);clreol(); printf("%s",stud.name); gotoxy(X1+9,Y1); printf("%c",stud.sex); gotoxy(X1+(2*9),Y1); printf("%d",stud.studID); gotoxy(X1+(3*9),Y1); printf("%d",stud.classID); gotoxy(X1+(4*9),Y1); printf("%d",stud.english); gotoxy(X1+(5*9),Y1); printf("%d",stud.math); gotoxy(X1+(6*9),Y1); printf("%d",stud.computer); gotoxy(X1,Y1+1);printf("Do you want to modify this record?y/n");yn=getchar(); getchar(); if(yn=='n'||yn=='N') {fwrite(&stud,sizeof(stud),1,temp);yn='s';Y1++;} else { gotoxy(X1,++Y1);clreol();printf("\b%c",16);/*return start position*/ gets(stud.name);gotoxy(X1+9,Y1);printf("\b%c",16); stud.sex=getchar();getchar();gotoxy(X1+(2*9),Y1);printf("\b%c",16); gets(numstr);stud.studID=atoi(numstr);gotoxy(X1+(3*9),Y1);printf("\b%c",16); gets(numstr);stud.classID=atoi(numstr);gotoxy(X1+(4*9),Y1);printf("\b%c",16); gets(numstr);stud.english=atoi(numstr);gotoxy(X1+(5*9),Y1);printf("\b%c",16); gets(numstr);stud.math=atoi(numstr);gotoxy(X1+(6*9),Y1);printf("\b%c",16); gets(numstr);stud.computer=atoi(numstr);gotoxy(X1,Y1+++1); stud.recycle=0; stud.total=stud.english+stud.computer+stud.math; stud.average=(stud.total)/3; fwrite(&stud,sizeof(stud),1,temp);yn='s';printf("Modify Successfully!!"); } } if(yn!='s') {fwrite(&stud,sizeof(stud),1,temp);yn='';} yn=''; } if(!sum) {printf("\nPress any key return to Menu....");fclose(fp);fclose(temp);remove("temp.txt");getch();return;} fclose(fp); fclose(temp); remove("RECORD"); rename("temp.txt","RECORD"); getch(); return; } /*Modify end*/
/*Search start*/ void search(void) { int go,Y1=3,once=0,i=0; char numstr[20]; FILE *fp; if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} cleardevice(); printf("Input the StudID:"); gets(numstr);go=atoi(numstr); while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle&&stud.studID==go) { if(++once==1) { Y1=2; gotoxy(X2,Y1); printf("Name"); gotoxy(X2+9,Y1); printf("Sex"); gotoxy(X2+(2*9),Y1); printf("StudID"); gotoxy(X2+(3*9),Y1); printf("ClassID"); gotoxy(X2+(4*9),Y1); printf("English"); gotoxy(X2+(5*9),Y1); printf("Math"); gotoxy(X2+(6*9),Y1); printf("Computer"); gotoxy(X2+(7*9),Y1); printf("Total"); gotoxy(X2+(8*9),Y1++); printf("Aver"); } gotoxy(X2,Y1);clreol(); printf("%s",stud.name);gotoxy(X2+(1*9),Y1); printf("%c",stud.sex);gotoxy(X2+(2*9),Y1); printf("%d",stud.studID);gotoxy(X2+(3*9),Y1); printf("%d",stud.classID);gotoxy(X2+(4*9),Y1); printf("%d",stud.english);gotoxy(X2+(5*9),Y1); printf("%d",stud.math);gotoxy(X2+(6*9),Y1); printf("%d",stud.computer);gotoxy(X2+(7*9),Y1); printf("%d",stud.average);gotoxy(X2+(8*9),Y1); printf("%d",stud.total);gotoxy(X2,++Y1); i++; if(i%20==0){printf("Press any key to continue…");getch();once=0;} } } printf("Press any key return to Menu....");getch(); fclose(fp); return; } /*Search end*/
/*Insert start*/ void insert(void) { int go,Y1=3,once=0,sum=0; char numstr[20],yn='n'; FILE *fp,*temp; temp=fopen("temp.txt","wb"); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} cleardevice(); printf("Choose the StudID:"); scanf("%d",&go);getchar(); while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle&&stud.studID==go) { sum++; if(++once==1) { Y1=2; gotoxy(X1,Y1); printf("Name"); gotoxy(X1+9,Y1); printf("Sex"); gotoxy(X1+(2*9),Y1); printf("StudID"); gotoxy(X1+(3*9),Y1); printf("ClassID"); gotoxy(X1+(4*9),Y1); printf("English"); gotoxy(X1+(5*9),Y1); printf("Math"); gotoxy(X1+(6*9),Y1); printf("Computer"); gotoxy(X1,++Y1); } gotoxy(X1,Y1);clreol(); printf("%s",stud.name); gotoxy(X1+9,Y1); printf("%c",stud.sex); gotoxy(X1+(2*9),Y1); printf("%d",stud.studID); gotoxy(X1+(3*9),Y1); printf("%d",stud.classID); gotoxy(X1+(4*9),Y1); printf("%d",stud.english); gotoxy(X1+(5*9),Y1); printf("%d",stud.math); gotoxy(X1+(6*9),Y1); printf("%d",stud.computer); gotoxy(X1,Y1+1); printf("Do you want to insert before this record ?y/n");yn=getchar(); getchar(); if(yn=='n'||yn=='N') {fwrite(&stud,sizeof(stud),1,temp);yn='s';} else { temp2=stud; gotoxy(X1,++Y1);clreol();/*return start position*/ gets(stud.name);gotoxy(X1+9,Y1); stud.sex=getchar();getchar();gotoxy(X1+(2*9),Y1); gets(numstr);stud.studID=atoi(numstr);gotoxy(X1+(3*9),Y1); gets(numstr);stud.classID=atoi(numstr);gotoxy(X1+(4*9),Y1); gets(numstr);stud.english=atoi(numstr);gotoxy(X1+(5*9),Y1); gets(numstr);stud.math=atoi(numstr);gotoxy(X1+(6*9),Y1); gets(numstr);stud.computer=atoi(numstr);printf("\n"); stud.recycle=0; stud.total=stud.english+stud.computer+stud.math; stud.average=(stud.total)/3; fwrite(&stud,sizeof(stud),1,temp); fwrite(&temp2,sizeof(stud),1,temp); printf("Insert Successfully!!"); yn='s'; } } if(yn!='s') {fwrite(&stud,sizeof(stud),1,temp);yn='';} yn=''; } if(!sum) {printf("\nError!!Press any key return to Menu....");fclose(fp);fclose(temp);remove("temp.txt");getch();} fclose(fp); fclose(temp); remove("RECORD"); rename("temp.txt","RECORD"); getch(); return; } /*Insert end*/
/*recycle start*/ void recycle(void) { int Y1=3,i=0,sum=0,once=1,i2=0; FILE *fp; cleardevice(); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} while(fread(&stud,sizeof(stud),1,fp)) sum++; rewind(fp); if(sum==0) {printf("\nNo record in file.Pass any key return to Menu..");getch();return;} while(fread(&stud,sizeof(stud),1,fp)==1) { if(once==1) {Y1=2; clrscr(); gotoxy(X2,Y1); printf("Name"); gotoxy(X2+9,Y1); printf("Sex"); gotoxy(X2+(2*9),Y1); printf("StudID"); gotoxy(X2+(3*9),Y1); printf("ClassID"); gotoxy(X2+(4*9),Y1); printf("English"); gotoxy(X2+(5*9),Y1); printf("Math"); gotoxy(X2+(6*9),Y1); printf("Computer"); gotoxy(X2+(7*9),Y1); printf("Total"); gotoxy(X2+(8*9),Y1++); printf("Aver"); once=0; } if(stud.recycle) { gotoxy(X2,Y1); printf("%s",stud.name);gotoxy(X2+(1*9),Y1); printf("%c",stud.sex);gotoxy(X2+(2*9),Y1); printf("%d",stud.studID);gotoxy(X2+(3*9),Y1); printf("%d",stud.classID);gotoxy(X2+(4*9),Y1); printf("%d",stud.english);gotoxy(X2+(5*9),Y1); printf("%d",stud.math);gotoxy(X2+(6*9),Y1); printf("%d",stud.computer);gotoxy(X2+(7*9),Y1); printf("%d",stud.average);gotoxy(X2+(8*9),Y1); printf("%d",stud.total);gotoxy(X2,++Y1);i2++; } if(++i==sum) {printf("\nPress any key return to Menu.....");getch();break;} if(sum>20&&i2!=0) {if((i2%20)==0){printf("\nPress any key to continue.....");getch();once=1;i2=0;}} } fclose(fp); return; } /*end recycle*/
/*Recovery start*/ void recovery(void) { int go,Y1=3,once=0,sum=0; char numstr[20],yn='n'; FILE *fp,*temp; temp=fopen("temp.txt","wb"); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} cleardevice(); printf("Choose the StudID:"); scanf("%d",&go);getchar(); while(fread(&stud,sizeof(stud),1,fp)) { if(stud.recycle&&stud.studID==go) { sum++; if(++once==1) { Y1=2; gotoxy(X1,Y1); printf("Name"); gotoxy(X1+9,Y1); printf("Sex"); gotoxy(X1+(2*9),Y1); printf("StudID"); gotoxy(X1+(3*9),Y1); printf("ClassID"); gotoxy(X1+(4*9),Y1); printf("English"); gotoxy(X1+(5*9),Y1); printf("Math"); gotoxy(X1+(6*9),Y1); printf("Computer"); gotoxy(X1,++Y1); } gotoxy(X1,Y1);clreol(); printf("%s",stud.name); gotoxy(X1+9,Y1); printf("%c",stud.sex); gotoxy(X1+(2*9),Y1); printf("%d",stud.studID); gotoxy(X1+(3*9),Y1); printf("%d",stud.classID); gotoxy(X1+(4*9),Y1); printf("%d",stud.english); gotoxy(X1+(5*9),Y1); printf("%d",stud.math); gotoxy(X1+(6*9),Y1); printf("%d",stud.computer); gotoxy(X1,Y1+1); printf("Do you want to Recovery this record?y/n");yn=getchar(); getchar(); if(yn=='n'||yn=='N') {fwrite(&stud,sizeof(stud),1,temp);yn='s';} else { gotoxy(X1,++Y1);clreol();/*return start position*/ stud.recycle=0; fwrite(&stud,sizeof(stud),1,temp);yn='s';printf("Recovery Successfully!!"); } } if(yn!='s') {fwrite(&stud,sizeof(stud),1,temp);yn='';} yn=''; } if(!sum) {printf("\nPress any key return to Menu....");fclose(fp);fclose(temp);remove("temp.txt");getch();return;} fclose(fp); fclose(temp); remove("RECORD"); rename("temp.txt","RECORD"); getch(); return; } /*Recovery end*/
/*Delete complete. start*/ void realdel(void) { int go,Y1=3,once=0,sum=0; char numstr[20],yn='n'; FILE *fp,*temp; temp=fopen("temp.txt","wb"); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} cleardevice(); printf("Choose the StudID:"); scanf("%d",&go);getchar(); while(fread(&stud,sizeof(stud),1,fp)) { if(stud.recycle&&stud.studID==go) { sum++; if(++once==1) { Y1=2; gotoxy(X1,Y1); printf("Name"); gotoxy(X1+9,Y1); printf("Sex"); gotoxy(X1+(2*9),Y1); printf("StudID"); gotoxy(X1+(3*9),Y1); printf("ClassID"); gotoxy(X1+(4*9),Y1); printf("English"); gotoxy(X1+(5*9),Y1); printf("Math"); gotoxy(X1+(6*9),Y1); printf("Computer"); gotoxy(X1,++Y1); } gotoxy(X1,Y1);clreol(); printf("%s",stud.name); gotoxy(X1+9,Y1); printf("%c",stud.sex); gotoxy(X1+(2*9),Y1); printf("%d",stud.studID); gotoxy(X1+(3*9),Y1); printf("%d",stud.classID); gotoxy(X1+(4*9),Y1); printf("%d",stud.english); gotoxy(X1+(5*9),Y1); printf("%d",stud.math); gotoxy(X1+(6*9),Y1); printf("%d",stud.computer); printf("\nDo you want to Delete complete this record?y/n");yn=getchar(); getchar(); if(yn=='n'||yn=='N') {fwrite(&stud,sizeof(stud),1,temp);yn='s';} else { gotoxy(X1,++Y1);clreol();/*return start position*/ yn='s';printf("Delete completed Successfully!!"); } } if(yn!='s') {fwrite(&stud,sizeof(stud),1,temp);yn='';} yn=''; } if(!sum) {printf("\nPress any key return to Menu....");} fclose(fp); fclose(temp); remove("RECORD"); rename("temp.txt","RECORD"); getch(); return; } /*Delete complete end*/
/*statistics start*/ void statistics(void) { int all_pass=0,com_pass=0,math_pass=0,good=0,member=0,en_pass=0; float en_aver=0.0,com_aver=0.0,math_aver=0.0,all_aver=0.0; float total=0.0; FILE *fp; cleardevice(); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} while(fread(&stud,sizeof(stud),1,fp)){if(!stud.recycle)member++;} rewind(fp); while(fread(&stud,sizeof(stud),1,fp)) { if(stud.english>=60||!stud.recycle)en_pass++; }rewind(fp);/*英语过了的人数*/ while(fread(&stud,sizeof(stud),1,fp)) { if(stud.computer>=60||!stud.recycle)com_pass++; }rewind(fp);/*电脑过了的人数*/ while(fread(&stud,sizeof(stud),1,fp)) { if(stud.math>=60||!stud.recycle)math_pass++; }rewind(fp);/*数学过了的人数*/ while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle)total+=stud.total; }all_aver=total/member;total=0;rewind(fp);/*总平均分*/ while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle)total+=stud.english; }en_aver=total/member;total=0;rewind(fp);/*英语平均分*/ while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle)total+=stud.computer; }com_aver=total/member;total=0;rewind(fp);/*电脑平均分*/ while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle)total+=stud.math; }math_aver=total/member;total=0;rewind(fp);/*数学平均分*/ while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle)if(stud.math>=60&&stud.computer>=60&&stud.english>=60)all_pass++;}rewind(fp); while(fread(&stud,sizeof(stud),1,fp)) { if(!stud.recycle)if(stud.math>=80&&stud.computer>=80&&stud.english>=80)good++;}rewind(fp); setcolor(8); circle(320,240,198); setcolor(7); circle(320,240,199); setcolor(15); circle(320,240,200); setcolor(7); circle(320,240,199); setcolor(8); circle(320,240,198); setcolor(8); line(199,139,439,139); setcolor(15); line(200,140,440,140); settextstyle(1,0,6); setcolor(7); outtextxy(210,80,"Statistics"); setcolor(15); outtextxy(208,78,"Statistics"); settextstyle(0,0,1);
outtextxy(200,164,"EN_Average:"); gotoxy(45,11);printf("%f",en_aver); outtextxy(200,182,"Com_Average:");gotoxy(45,12);printf("%f",com_aver); outtextxy(200,198,"Math_Average:");gotoxy(45,13);printf("%f",math_aver); outtextxy(200,214,"Toal_Average:");gotoxy(45,14);printf("%f",all_aver);
outtextxy(200,245,"EN_Pass:"); gotoxy(45,16);printf("%d",en_pass); outtextxy(200,263,"Com_Pass:");gotoxy(45,17);printf("%d",com_pass); outtextxy(200,278,"Math_Pass:");gotoxy(45,18);printf("%d",math_pass); outtextxy(200,294,"Toal_Pass:");gotoxy(45,19);printf("%d",all_pass); outtextxy(200,310,"Good:");gotoxy(45,20);printf("%d",good); settextstyle(1,0,2); outtextxy(200,350,"Member:");gotoxy(45,23);printf("%d",member); circle(30,430,5); circle(50,380,10); circle(80,330,20); circle(610,430,5); circle(590,370,10); circle(560,330,20); circle(610,30,5); circle(590,80,10); circle(560,130,20); circle(30,30,5); circle(50,80,10); circle(80,130,20);
fclose(fp); getch(); return; } /*Statistics end*/
/*graphsics start*/
int face(void) { int driver,mode,key,po=0; void mok(void); int up(int point); int down(int point); driver=VGA;mode=VGAHI; initgraph(&driver,&mode,""); setbkcolor(BLUE); putpixel(30,20,RED); circle(30,20,100); /*right top*/ circle(600,20,100); /*left top*/ circle(30,460,100); /*right down*/ circle(600,460,100); /*left down*/ circle(320,240,300); /*the biggest*/ settextstyle(4,0,4); textcolor(BLUE); outtextxy(230,50,"==menu==");/**/ gotoxy(30,8); printf("1.Add a new record."); /*追加*/ gotoxy(30,9); printf("2.List all records."); /*显示*/ gotoxy(30,10);printf("3.Delete records."); /*删除*/ gotoxy(30,11);printf("4.Modify."); /*修改*/ gotoxy(30,12);printf("5.Search."); /*查找*/ gotoxy(30,13);printf("6.Sort."); /*排序*/ gotoxy(30,14);printf("7.Insert."); /*插入记录*/ gotoxy(30,15);printf("8.Recovery record."); /*恢复数据*/ gotoxy(30,16);printf("9.Statistics."); /*统计*/ gotoxy(30,17);printf("10.Recycle."); /*查看回收站*/ gotoxy(30,18);printf("11.Delete complete."); /*彻底删除*/ gotoxy(30,19);printf("0.Exit."); gotoxy(28,8+po);printf("%c",16);/*指针指向1.Add....位置*/ po=1; while(1) { key=bioskey(0); if(po==1){gotoxy(28,19);printf(" ");} if(po==0){gotoxy(28,8);printf(" ");} if(key==0x1c0d) { if(po==12)exit(0); else return po; } if(key==0x4800) /*up↑*/ { if(po==1) po=12; else po=po--; gotoxy(28,8+po);printf(" "); gotoxy(28,7+po);printf("%c",16); gotoxy(32,23);printf("You choose %d ",po==12?0:po); }
if(key==0x5000) /*down↓*/ { if(po==12) po=1 ; else po++; gotoxy(28,6+po);printf(" "); gotoxy(28,7+po);printf("%c",16); gotoxy(32,23);printf("You choose %d ",po==12?0:po); } if(po!=1){gotoxy(28,8);printf(" ");} if(po!=12){gotoxy(28,19);printf(" ");} }
} void mok(void) { int i=1,j=0,clo; for(j=0;j<2;j++) { if(i<100) { for(i=1;i<100;i+=10) { circle(30,20,i);} for(i=1;i<100;i+=10)circle(30,460,i); for(i=1;i<100;i+=10)circle(600,20,i); for(i=1;i<100;i+=10)circle(600,460,i); } } } /*graphics end*/
/*Sort start*/ void sort(void) { int a1=0,sum=0,f1; long address,address2; void sortlist(void); FILE *fp,*temp,*tempx; cleardevice(); temp=fopen("temp","wb"); tempx=fopen("tempx","wb"); if ((fp=fopen("RECORD","rb"))==NULL){printf("I don't find any file.");getch();return;} while(fread(&stud,sizeof(stud),1,fp)) {fwrite(&stud,sizeof(stud),1,tempx);sum++;} fclose(tempx); tempx=fopen("tempx","rb"); rewind(fp);
gotoxy(26,7);printf("Please choose a sort mode:"); gotoxy(29,8);printf("1.StudentID up mode[%c]:",24); gotoxy(29,9);printf("2.StudentID down mode[%c]:",25); gotoxy(29,10);printf("3.Math up mode[%c]:",24); gotoxy(29,11);printf("4.Math down mode[%c]:",25); gotoxy(29,12);printf("5.Total up mode[%c]:",24); gotoxy(29,13);printf("6.Total down mode[%c]:",25); gotoxy(29,14);printf("You choose:");scanf("%d",&f1);getchar(); while(fread(&stud,sizeof(stud),1,fp)) { while(fread(&temp2,sizeof(stud),1,tempx)) { switch(f1) { case 1 : if(stud.studID<=temp2.studID)a1++;break; case 2 : if(stud.studID>=temp2.studID)a1++;break; case 3 : if(stud.math<=temp2.studID)a1++;break; case 4 : if(stud.math>=temp2.studID)a1++;break; case 5 : if(stud.total<=temp2.studID)a1++;break; case 6 : if(stud.total>=temp2.studID)a1++;break; } } stud.sort=a1; a1=0; fwrite(&stud,sizeof(stud),1,temp); rewind(tempx); } fclose(fp); fclose(temp); fclose(tempx); remove("RECORD"); remove("tempx"); rename("temp","RECORD"); sortlist(); } /*sort end*/
/*sortlist all record*/ void sortlist(void) { int Y1=3,i=0,sum=0,once=1,sum2,i2=0; FILE *fp; cleardevice(); if((fp=(fopen("RECORD","rb")))==NULL) {printf("I can not open this file.");getch();return;} while(fread(&stud,sizeof(stud),1,fp)) sum++; sum2=sum; rewind(fp); if(sum==0) {printf("\nNo record in file.Pass any key return to Menu..");getch();return;} while(sum2) { if(once==1)/*显示列表*/ {Y1=2; clrscr(); gotoxy(X2,Y1); printf("Name"); gotoxy(X2+9,Y1); printf("Sex"); gotoxy(X2+(2*9),Y1); printf("StudID"); gotoxy(X2+(3*9),Y1); printf("ClassID"); gotoxy(X2+(4*9),Y1); printf("English"); gotoxy(X2+(5*9),Y1); printf("Math"); gotoxy(X2+(6*9),Y1); printf("Computer"); gotoxy(X2+(7*9),Y1); printf("Aver"); gotoxy(X2+(8*9),Y1++); printf("Total"); once=0; } while(fread(&stud,sizeof(stud),1,fp)) { if(stud.sort==sum2) { if(!stud.recycle) { gotoxy(X2,Y1); printf("%s",stud.name);gotoxy(X2+(1*9),Y1); printf("%c",stud.sex);gotoxy(X2+(2*9),Y1); printf("%d",stud.studID);gotoxy(X2+(3*9),Y1); printf("%d",stud.classID);gotoxy(X2+(4*9),Y1); printf("%d",stud.english);gotoxy(X2+(5*9),Y1); printf("%d",stud.math);gotoxy(X2+(6*9),Y1); printf("%d",stud.computer);gotoxy(X2+(7*9),Y1); printf("%d",stud.average);gotoxy(X2+(8*9),Y1); printf("%d",stud.total);gotoxy(X2,++Y1); i++; } } }rewind(fp); if(i2++==sum) {printf("\nPress any key return to Menu.....");getch();fclose(fp);return;} if(sum>20&&i!=0) {if((i%20)==0){printf("\nPress any key to continue.....");getch();once=1;}} sum2--; } getch(); fclose(fp); return; } /*end sortlist*/

|