C language curriculum design

xiaoxiao2021-03-06  57

#define record record.txt # define x1 6 # Define x2 2 # include #include #include #include #include # Include / * # include "class / cartoon.c" * // * definition struct * / structure {char name [10]; char sex; int studiD; int classid; int english; int math; int computer INT Recycle; int average; int us; int sort;} stud

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 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, 8); 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 Management") 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); Void Del (Void); Void Search; Void Sort (Void) void insert (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; casse 5: search (); Break; Case 6: sort (); break; case 7: insert (); break; case 8: recovery (); break; case 9: statistics (); break; case 10: recycle (); break; casse 11: Realdel (); break; casp 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 n); gotoxy (x1 9, y1); Printf ("/ b% c", 16); stud. = getchar (); getchar (); gotoxy (x1 (2 * 9), Y1); Printf ("/ b% c", 16); gets (numstr); studOstudid = ATOI (NUMSTR); gotoxy (x1 (3 * 9), y1); Printf ("/ b% C", 16); gets (numstr); stud.xy; 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); studOMATH = 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 (& Stud), 1, fp) Sum ; Rewind (fp); if (SUM == 0) {Printf ("/ nno record in file.pass any key return to menu .."); getch (); return;} while (FREAD, 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", STU D. 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) {ix ((i2% 20) == 0 ) {Printf ("/ npress any key to pay ...); getch (); overce = 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 = (" RECORD "," RB "))) == null) {Printf (" i can not open this file. "); getCH (); } ("Choose the Studi:"); Gets (Numstr); GO = ATOI (NUMSTR);

While (& Stud), 1, fp) {if (! "== GO) {SUM ; if ( overce == 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.en GLISH); Gotoxy (x2 (5 * 9), y1); Printf ("% d", stud.math); gotoxy (x2 (6 * 9), y1); Printf ("% d", stud.computer) (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 Delte this Record? Y / N"); Yn = getchar (); getchar (); if (Yn == 'n' || Yn == 'N ') {FWRITE (& Stud), 1, Temp); Yn =' s';} else {stud.recycle = 1;

FWRITE (& Stud), 1, Temp); YN = 's';}}} (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 = ("RECORD", "RB"))) == null) {Printf ("i can not open this file."); getch () Return;} cleardevice (); Printf ("Choose the Studi:"); Scanf ("% D", & Go); getchar (); while (& stud, sizeof (stud), 1, fp) {if (! stud.recycle && stud.studid == GO) {SUM ; if ( overce == 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 (studOXY); gotoxy (x1 9, y1); Printf ("/ b% C", 16); stud. = getchar (); getchar (); gotoxy (x1 (2 * 9), y1) PRINTF ("/ b% C", 16); gets (NUMST); stud.studid = ATOI (NUMSTR); gotoxy (x1 (3 * 9), Y1); Printf ("/ b% c", 16) Gets (NUMSTR); Stud. ClassID = ATOI (NUMST); 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); studOMATH = ATOI (NUMSTR); gotoxy (x1 (6 * 9), Y1); Printf ("/ b% c", 16); gets (numstr); stud cputer = ATOI (NUMSTR); gotoxy (x1, y1 1); stud.Recycle = 0; stud.total = Stud Vector stud.math; stud.average = (stud.total) / 3; FWRITE (& Stud), 1, TEMP); Yn = 's'; Printf ("Modify SuccessFully! ! ");}} F (yn! = 'S') {FWRITE (& ST UD, 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 =) RB "))) == NULL) {Printf (" i can not open this file. "); getCh (); return;} clearDevice (); Printf (" Input the studiD: "); gets (numstr); GO = ATOI (NUMSTR); While (& Stud, SizeOf (Stud), 1, FP)) {if (! "== 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");} g OTOXY (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 .... "); 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 = ("RECORD", "RB"))) == null) {Printf ("i can not open this file."); getch () Return;} cleardevice (); Printf ("Choose the Studi:"); Scanf ("% D", & Go); getchar (); while (& stud, sizeof (stud), 1, fp) {if (! stud.recycle && stud.studid == GO) {SUM ; if ( overce == 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 (); Prin TF ("% 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. = getchar (); getchar (); gotoxy (x1 (2 * 9), y1); gets (numstr); studOxy (x1 ); gotoxy (x1 (3 * 9), y1); gets (NUMST); stud.xy; gotoxy (x1 (4 * 9), y1); Gets (NUMSTR); studOENGLISH = ATOI (NUMSTR); gotoxy (X1 (5 * 9), y1); gets (NUMSTR); stud = 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 ), 1, temp); FWRITE (& TEMP2, SIZEOF (STUD), 1, TEMP); Printf ("INSERT SUCCESSFULLLY !!"); Yn = 's';}} f (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 =) Record "," RB "))) == NULL) {Printf (" i can not open this file. "); Getch (); return;} while (& 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 ("& 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 (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", STU D. 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 pay ...); getCH (); ONCE = 1; I2 = 0;}}} fclose (fp);} / * 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 = ("RECORD", "RB"))) == null) {Printf ("i can not open this file."); getch () Return;} cleardevice (); Printf ("Choose the Studi:"); Scanf ("% D", & Go); getchar (); while (& stud, sizeof (stud), 1, fp) {if (stud.recycle && stud.studid == GO) {SUM ; if ( overce == 1) {y1 = 2; gotoxxy (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 (); print f ("% 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 {gotox (x1, y1); clreol (); / * return start position * / stud.recycle = 0; fwrite (& stud, Sizeof) STUD), 1, TEMP); YN = 's'; Printf ("Recovery SuccessFully !!);}}}} (}! = 's') {FWRITE (& 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 completion. 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 = ("RECORD", "RB"))) == NULL) {Printf ("i can not open this file."); getch (); Return;} Cleardevice (); Printf ("Choose The Studi:"); Scanf ("% D", & Go); getchar (); While (Fread (& Stud), 1, fp) {IF (stud.recycle && stud.studidiD == GO) {SUM ; if ( overce == 1) {y1 = 2; gotoxxy (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 wantd? 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! ! ");}} {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 completion 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 = ("RECORD", "RB")) == null) {printf ("i can not open this file. "); getCH (); return;} while (" & stud (& stud, sizeof (stud), 1, fp) {if (! ", (!,});} rebind (fp); While (FREAD (& stud, Sizeof) STUD, 1, fp) {if (stud.English> = 60 ||! stud.recycle) en_pass ;} REWIND (FP); / * English Overview * / while (& stud, Sizeof (studs) ), 1, fp) {if (stud.computer> = 60 ||! Stud.recycle) COM_PASS ;} REWIND (FP); / * Computer overnight * / while ("& stud, sizeof (stud) , 1, fp) {if (stud.math> = 60 ||! Stud.recycle) Math_pass ;} REWIND (FP); / * Mathemathematical number * / while (& stud (& stud, sizeof (stud), 1, fp) {if (! Stud.recycle) Total = stud.total;} all_aver = Total / Member; Total = 0; Rewind (fp); / * Total average divide * / while (FREAD (& Stud, Sizeof) STUD), 1, fp) {if (! stud.recycle) Total = stud.English;} en_aver = Total / Member; Total = 0; Rewind (fp); / * English Average * / While (FREAD (& Stud) Sizeof (stud), 1, fp) {if (! stud .r Ecycle) Total = Stud.computer;} com_aver = Total / Member; Total = 0; Rewind (fp); / * Computer average * / while (& Stud, SizeOf (Stud), 1, FP) {IF ( Total = stud.math;} Math_aver = Total / Member; Total = 0; ReWind (fp); / * Mathematical Average Division * / While (& Stud), 1, FP)) {if (! "= 60 && stud.Computer> = 60 && stud.English> = 60) All_pass ;} REWIND (FP); While (FREAD (& Stud), 1, FP) ) {if (! stud.recycle) IF (stud.math> = 80 && seat.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 down; int point; driver = vga; mode = vgahi; Initgraph (& Driver, & Mode) (& 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. "); / * Add * / gotoxy (30, 9); Printf (" 2.List all Records. "); / * Display * / gotoxy (30, 10); Printf (" 3. Delete Records. "); / * Delete * / gotoxy (30, 11); Printf (" 4.Modify. "); / * Modify * / gotoxy (30, 12); Printf ("5.Search."); / * Find * / gotoxy (30, 13); Printf ("6.sort."); / * Sort * / gotoxy (30, 14); Printf ("7.insert."); / * Insert record * / gotoxy (30, 15); Printf ("8.Recovery Record."); / * Recovery data * / gotoxy (30, 16); Printf ("9.statistics."); / * Statistics * / gotoxy (30, 17); Printf ("10.Recycle."); / * View Recycle Bin * / Gotoxy (30, 18); Printf (" 11.Delete completion. "); / * Completely delete * / gotoxy (30, 19); Printf (" 0.exit. "); Gotoxy (28, 8 po); Printf ("% C ", 16); / * Pointer points to 1.Add .... position * / po = 1; while (1) {key = bioskey (0); if (PO == 1) {gotoxy (28, 19); Printf ("") } IF (PO == 0) {gotoxxy (28, 8); Printf ("");} if (key == 0x1c0d) {IF (PO == 12) exit (0); Else Return Po;} (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 choise% 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 (& Stud) {FWRITE (& 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 choise:"); scanf ("% d", & f1); getchar (); while (Fread (& Stud), 1, FP) {while (Fread (& Temp2, SizeOf (Stud), 1, Tempx) {Switch (F1) {Case 1: IF (stud.studid <= TEMP2. Studier 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;}}. Sort = a1; A1 = 0; FWRITE (& Stud), 1, TEMP); Rewind (Tempx); fclose (fp); 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 ("& 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) / * Display list * / {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 (& Stud) SIZEOF (STUD), 1, FP) {if (stud.sort == Sum2) {if (! stud.recycle) {gotoxy (x 2, 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);

转载请注明原文地址:https://www.9cbs.com/read-83585.html

New Post(0)