My C language student score management system
Author: matoku
#include
Return to the previous re-enter * /}}}} Printf ("Please enter the student name:"); scanf ("% s", & p1-> name); / * Enter the student name * / printf ("Please enter C grade (0 ~ 100): "); / * Enter C scores, the score should be at 0-100 * / scanf ("% f ", & p1-> cyuyan; while (p1-> cyuyan <0 || p1-> cyuyan> 100 ) {Getchar (); printf ("Input error, please re-enter C grade"); / * Enter an error, re-enter the C grade until * / scanf ("% f", & p1-> cyuyan);} printf "Please enter the VB score (0 ~ 100):"); / * Enter the VB score, the score should be 0-100 * / scanf ("% f", & p1-> vbyuyan); while (p1-> vbyuyan <0 | | p1-> vbyuyan> 100) {getChar (); Printf ("Input error, re-enter VB score"); / * Enter an error, re-enter the VB score until * / scanf ("% f", & p1- > vbyuyan;} printf ("Please enter SQL score (0 ~ 100):"); / * Enter SQL scores, the score should be at 0-100 * / scanf ("% f", & p1-> sqlyuyan; while P1-> SQLYUYAN <0 || P1-> SQLYUYAN> 100) {getchar (); printf ("Input error, re-enter SQL score"); scanf ("% f", & p1-> sqlyuyan);} / * Enter an error, re-enter the SQL score until it is correct * / head = null; while (p1-> number! = 0) {n = n 1; if (n == 1) Head = p1; Else P2-> Next = P1; p2 = p1; p1 = (score *) malloc (len); Printf ("Please enter student data, lose 0 exit! / n"); Repeat2: Printf ("Please enter the student number" (student number should be greater than 0 "); Scanf ("% d ", & p1-> Number); / * Enter the school number, the students should be greater than 0 * / while (p1-> number <0) {getchar (); printf ("Input error, please re-enter the student number:"); scanf ("% D", & p1-> number;} / * When the graph is character or less than 0, the program error, prompts to re-enter the school number * / if (p1-> number == 0) goto end; / * When the entered school number is 0, go to the end, end the creation of a list * / else {p3 = head; if (n> 0) {for (i = 0; i ) {IF (p1-> number! = P3-> number) P3 = p3-> next; else {printf ("Study number repeat, please reload! / N"); goto repeat2; / * When entering the students Already, the program error is wrong, return to the previous re-enter * /}}}} Printf ("Please enter the student name:"); scanf ("% s", & p1-> name); / * Enter the student name * / printf (" Please enter C grade (0 ~ 100): "); scanf ("% f ", & p1-> cyuyan); / * Enter C grade, score should be in 0-100 * / while (p1-> cyuyan <0 || P1-> cyuyan> 100) {getChar (); Printf ("Input error, re-enter C grade"); scanf ("% f", & p1-> cyuyan;} / * input error, re-enter C grade until Correct * / printf ("Please enter VB score (0 ~ 100):"); scanf ("% f", & p1-> vbyuyan); / * Enter VB scores, scores should be in 0-100 * / while (P1 -> Vbyuyan <0 || P1-> Vbyuyan> 100) {getchar (); Printf ("Input error, please re-enter VB score"); scanf ("% f", & p1-> vbyuyan);} / * input Error, re-enter the VB score until it is correct * / printf ("Please enter the SQL score (0 ~ 100):"); scanf ("% f", & p1-> sqlyuyan; / * Enter SQL scores, scores should be in 0 -100 * / while (p1-> sqlyuyan <0 || p1-> sqlyuyan> 100) {getchar (); printf ("Input error, please re-enter SQL score"); scanf ("% f", & p1-> SQLYUYAN);} / * Enter an error, re-enter the SQL score until it is correct * /} End: p1 = head; p3 = p1; for (i = 1; i } / * =============================================== ================================================================// * ================================================= ====================================================== * / score * loading2311 (Score * HEAD) / * Function LOAD2311, Function: Read the student record from the file * / {score * p1, * p2; int m = 0; char filepn [10]; file * fp; printf ("Please enter the file path And file name: "); scanf ("% s ", filepn); / * Enter file path and name * / if ((fp = fopen (FilePn," R ")) == null) {printf (" Can't open ! file / n "); return 0;} fscanf (fp," test scores management system / n "); fscanf (fp," author: Xinjie class: E3 information Student ID: 24 / n "); fscanf (fp , "------------------------------------- / n"); fscanf ( FP, "| Learn / T | Name / T | C / T | VB / T | SQL / T | / N"); fscanf (fp, "--------------- ------------------------ / n "); / * Read in Form Domain * / Printf (" Exam Score Management System / N ") ; printf ( "author: Xinjie class: E3 information Student ID: 24 / n"); Printf ("----------------------------------- / n"); Printf ("| | Learn / T | Name / T | C / T | VB / T | SQL / T | / N"); Printf ("---------------- --------------------- / n "); / * Print Table Domain * / m = m 1; if (M == 1) {P1 = (score *) malloc (len); / * Open a new unit * / fscanf (FP, "% D% S% f% f% f", & p1-> number, p1-> name, & p1-> cyuyan, & p1-> vbyuyan, & p1-> sqlyuyan; Printf ("|% D / T |% S / T |% .1F / t |% .1f / t |% .1f / t | / n", p1-> Number, p1-> name, p1-> cyuyan, p1-> vbyuyan, p1-> sqlyuyan); / * File read and display * / head = null; do {n = n 1; if (n == 1 HEAD = P1; ELSE P2-> Next = P1; P2 = P1; P1 = (score *) malloc (len); / * Open a new unit * / fscanf (FP, "% D% S% F% f%) F / N ", & P1-> Number, P1-> Name, & P1-> cyuyan, & p1-> vbyuyan, & p1-> sqlyuyan); Printf (" |% D / T |% S / T |% .1f / t |% .1f / t |% .1f / t | / n ", p1-> number, p1-> name, p1-> cyuyan, p1-> vbyuyan, p1-> sqlyuyan); / * File read and display * /} While (fp)); p2-> next = p1; p1-> next = null; n = n 1;} printf ("-------------- ------------------------- / n "); / * Table Line * / fclose (fp); / * End read, Close the file * / return (head); / * ================================================================================================================================================================ ====================================================== * // * ============================================================================================================================================================================================================= ===================================================== * / score * Add2311 ( Score * Head, Score * STU / * Function Add2311, Function: Additional student data, and sequencing all student data from the number number number * / {score * p0, * p1, * p2, * p3, * max; int i, J; Float Fen; Char T [10]; P3 = stu = (score *) malloc (len); / * Open a new unit * / printf ("/ N input to increase the information!"); Repeat4: Printf ("Please enter the student number (student number) Should be greater than 0): "); SCANF ("% d ", & stu-> number); / * Enter the school number, the students should be greater than 0 * / while (stu-> number <0) {getchar (); printf "Enter an error, please re-enter the student number:"); scanf ("% d", & stu-> number);} / * Enter an error, re-enter the school number * / / ********* ******************************************* / IF (stu-> Number == 0) goto end2; / * When the input learned is 0, go to the end, end the addition * / else {p3 = head; if (n> 0) {for (i = 0; i } / ******************************************************* ****** / printf ("Enter the student name:"); scanf ("% s", stu-> name); / * Enter the student name * / printf ("Please enter C grade (0 ~ 100): "); Scanf ("% f ", & stu-> cyuyan; / * Enter C grade, score should be at 0-100 * / while (stu-> cyuyan <0 | stu-> cyuyan> 100) {GetChar ( ); Printf ("Enter error, re-enter C grade"); scanf ("% f", & stu-> cyuyan;} / * input error, re-enter C grade until * / printf ("Please enter VB Grade (0 ~ 100): "); scanf ("% f ", & stu-> vbyuyan; / * Enter VB score, score should be in 0-100 * / while (stu-> vbyuyan <0 || stu-> Vbyuyan> 100) {getChar (); Printf ("Enter an error, please re-enter the VB score"); scanf ("% f", & stu-> vbyuyan;} / * Enter an error, re-enter the VB score until it * / Printf ("Please enter SQL score (0 ~ 100):"); scanf ("% f", & stu-> sqlyuyan); / * Enter SQL scores, scores should be in 0-100 * / while (stu-> sqlyuyan <0 || stu-> sqlyuyan> 100) {getChar (); Printf ("Input error, re-enter SQL score"); scanf ("% f", & stu-> sqlyuyan);} / * Enter error, re- Enter SQL scores until it is correct to * / p1 = head; p0 = stu; if (head == null) {head = p0; p0-> next = null;} / * When the original list is empty, start from the first node Storage information * / else / * The original linked list is not empty * / {if (p1-> next == null) / * Find the end of the original linked list * / {p1-> next = P0; P0-> next = null; / * Connect it with the newly opened unit * /} else {while (p1-> next! = null) / * has not found the end, continue to find * / {p2 = P1; p1 = P1-> next;} p1-> next = p0; p0-> next = null;}} n = n 1; P1 = head; p0 = stu; for (i = 1; i } / * ============================================================================================================================================================================================== ================================================================// * =========================================================================================================================================================================================== ====================================================== * / score * search2311 (Score * HEAD) / * Function Search2311, Function: Query Student Scores * / {Int Number; Score * P1, * P2; Printf ("Enter the student number of the students you want to query,"); scanf ("% d", & number (Number! = 0) {if (head == null) {printf ("/ n No student information! / n"); return (head);} Printf ("----------------------------------- / n"); Printf ("| | Learn / T | Name / T | C / T | VB / T | SQL / T | / N"); Printf ("---------------- --------------------- / n "); / * Print Table Domain * / P1 = Head; While (Number! = P1-> Number && P1-> Next! = null) {P2 = P1; P1 = P1-> Next;} if (Number == P1-> Number) {Printf ("|% D / T |% S / T |% .1F / t |% .1f / t | % .1f / t | / n ", p1-> number, p1-> name, p1-> cyuyan, p1-> vbyuyan, p1-> sqlyuyan; printf (" ----------- ---------------------------- / n ");} / * Print form * / else printf ("% D is not There is this student! / N ", number); Printf (" Enter the student number of the students you want to query, "); scanf ("% d ", & number);} Printf (" has exited! / N "); Return (HEAD);} / * ============================================= ============================================================================================================================================================================================================= = * // * ================================================ ========================================================= * / score * del2311 (score * head) / * function DEL2311, Function: Delete student data * / {score * p1, * p2; int number; printf ("Enter the student number of the students you want to delete (exit when entering 0): "); Scanf ("% d ", & number); getchar (); while (number! = 0) / * Input Scholar is 0 to exit * / {if (Head == null) {printf (" / n no Any student information! / N "); return (head);} P1 = head; while (Number! = P1-> Number && p1-> next! = null) / * P1 pointing to the first node you want to find, and there is a node * / {p2 = p1; p1 = p1- > Next;} / * p1 after moving a node * / if (Number == P1-> Number) / * found * / {if (p1 == HEAD) Head = p1-> next; / * If P1 points The first node, the two node addresses gave a head * / else p2-> next = p1-> next; / * Otherwise, the next node address is assigned to the previous junction address * / printf ("delete :% D / N ", Number); n = n-1;} else printf ("% D does not exist this student! / n ", number); / * Can't find the node * / printf (" input Deleted student's student number: "); scanf ("% d ", & number); getchar ();} #ifdef debug printf (" already exited! / N "); # endifprintf (" The number of students now: % D! / n ", n); return (head); / * ================================================================================================================================================================ ============================================== * / / * ============================================================================================================================================================================================================= ==================================================== * / void print2311 (score * HEAD) / * Function Print2311, Function: Display Student Score * / {Score * P; if (Head == Null) {Printf ("/ N No Student Data! / N");} D / N ", N); Printf (" ------------------------------------- - / N "); Printf (" | Learn / T | Name / T | C / T | VB / T | SQL / T | / N "); Printf (" ---------- ---------------------------- / n "); / * Print Table Domain * / P = Head; Do {Printf ("|% D / T |% S / T |% .1f / t |% .1f / t |% .1f / t | / n", P-> Number, P-> Name, P-> Cyuyan, P-> vbyuyan, p-> sqlyuyan; printf ("----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ----- / n "); / * Print Table Domain * / P = P-> Next;} while (p! = null); / * Print is complete * /}} / * ====== ========================== ============================================================================================================================================================================================================= ============ ==================================== ============================================================================================================================================================================================================= ========== * / score * statistics2311 (score * head) / * function statistics2311, function: statistical student grade * / {float sum1 = 0, Sum2 = 0, SUM3 = 0, AVE1 = 0, AVE2 = 0, AVE3 = 0, MAX = 0, Min; Score * P; INT X, Y = 0, I = 0; P = HEAD; Printf ("1 personal total score average / T2 single subject) T3 total score / t4 total score minimum / N "); scanf ("% d ", & x); getchar (); Switch (x) / * Implement the function selection * / {case 1: if (head == null) {printf ("/ n without any student information! / n"); return (} / * linked list Empty * / else {printf ("--------------------------------------- ---------------- / n "); Printf (" | | Learn / T | Name / T | C / T | VB / T | SQL / T | total score / t | Average score / t | / n "); Printf (" -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ------------------- / n "); / * Print Table Domain * / while (p! = null) {Sum1 = P-> cyuyan P- > vbyuyan p-> sqlyuyan; / * Calculate personal points * / avE1 = SUM1 / 3; / * Calculate personal average * / printf ("|% D / T |% S / T |% .1f / t | % .1f / t |% .1f / t |% .1f / t |% .1f / t | / n ", p-> number, p-> name, p-> cyuyan, p-> vbyuyan, p- > SQLYUYAN, SUM1, AVE1); / * Print Results * / Printf ("------------------------------- ---------------------- / n "); / * Print Table Domain * / P = P-> Next;}} Return (Head); Break; Case 2: if (Head == Null) {Printf ("/ N No Student Data! / N"); Return (Head);} / * Link list is empty * / while (p! = NULL) {Sum1 = Sum1 P-> cyuyan; sum2 = sum2 p-> vbyuyan; sum3 = sum3 p-> sqlyuyan; / * calculation total division * / y = y 1; avE1 = sum1 / y; AVE2 = SUM2 / Y; AVE3 = SUM3 / Y; / * Calculate the average dividend * / p = p-> next; / * Make P point down one node * /} printf ("C The average points are% .1f / n ", AVE1); Printf (" VB Average is% .1F / N ", AVE2); Printf (" SQL Average is% .1F / N ", AVE3); / * Print Results * / Return (HEAD); Break; case 3: if (head == null) {printf ("/ n no student data! / n"); return (head);} / * Link table empty * / max = P-> cyuyan P- > vbyuyan p-> sqlyuyan; while (i / * ================================================================================================================================================================ ====================================================== * // * ============================================================================================================================================================================================================= ===================================================== * / save2311 (score * P1) / * Function SAVE2311, Function: Save students' information * / {file * fp; char filepn [20]; / * Used to store file save paths and file name * / printf ("Please enter file path and file name: "); Scanf ("% s ", filepn); if ((fp = fopen (filepn," w ") == null) {printf (" Cannot open file! / N "); return 0;} fprintf (fp, "test scores Management System / n"); fprintf (fp, "Author: Xinjie class: E3 Information Student ID: 24 / n"); fprintf (fp, "--------- ----------------------------- / n "); FPRINTF (FP," | Learn / T | Name / T | C / T | VB / T | SQL / T | / N "); FPRINTF (FP," ---------------------------------------------------------------------------------------- ------------- / n "); / * Print Table Domain * / while (p1! = null) {fprintf (fp,"% D / T% S / T%. 1F / T% .1f / t% .1f / t / n ", p1-> number, p1-> name, p1-> cyuyan, p1-> vbyuyan, p1-> sqlyuyan); p1 = p1-> next; / * Move a node * /} fclose (fp); Printf ("file already saved! / N"); return 0;} / * ================ ============================================================================================================================================================================================================= =========================== * // * =================== ============================================================================================================================================================================================================= ======================================================================================================================================================================== This function comes back to a pointer to the chain head * / {score * p, * max; int i, j, x; float fen; char t [10]; if (head == null) {printf ("/ n no Any student information, please establish a list first! / N "); return (head);} / * Link table is empty * / max = p = head; for (i = 0; i <80; i ) printf (" * " PRINTF ("1 Sort by Student Number / T2 According to Student Name Sort / T3 Press Cgraduate / N"); Printf ("4 Press VB Score / T5 Press SQL Score / T / N"); for (i = 0; i <80; i ) Printf ("*"); Printf ("Please select actions:"); scanf ("% d", & x); / * Select operation * / getchar (); switch ( X) / * Implement function with Switch statement * / {case 1: for (i = 1; i } Max = head; p = head; / * Re-enable max, p pointing to linked table * /} print2311 (head); Break; / * Print the contents of the list * / Case 2: for (i = 1; i Fen = max-> vbyuyan; max-> vbyuyan = p-> vbyuyan; p-> vbyuyan = fen; / * exchange the VB score in the front and rear nodes, make it matching the name * / FEN = max-> sqlyuyan; max-> sqlyuyan = p-> sqlyuyan; p-> sqlyuyan = fen; / * SQL score in the front and rear nodes, make it match the name * /}} P = head; max; max; max; max; max; max; max; max = head; }print2311 (head); Break; Case 3: for (i = 1; i STRCPY (T, Max-> Name); STRCPY (Max-> Name, P-> Name); STRCPY (P-> Name, T); / * Switch the name in the front and rear nodes to match the C grade * / FEN = max-> vbyuyan; max-> vbyuyan = p-> vbyuyan; p-> vbyuyan = fen; / * exchange the VB score in the front and rear nodes, make it match the C grade * / fen = max-> sqlyuyan Max-> sqlyuyan = p-> sqlyuyan; p-> sqlyuyan = fen; / * Switch's SQL score in the front and rear nodes, match the C grade * /}} P = head; max = head; }print2311 (HEAD); BREAK; Case 4: for (i = 1; i STRCPY (T, Max-> Name); STRCPY (Max-> Name, P-> Name); STRCPY (P-> Name, T); / * Switch the name in the front and rear nodes, make it matching the VB score * / Fen = max-> cyuyan; max-> cyuyan = p-> cyuyan; p-> cyuyan = fen; / * exchange the C score in the front and rear nodes, make it match the VB score * / fen = max-> sqlyuyan Max-> sqlyuyan = p-> sqlyuyan; p-> sqlyuyan = fen; / * Switch's SQL score in front-rear node, match the VB score * /}} P = head; max = head; }print2311 (HEAD); BREAK; Case 5: for (i = 1; i STRCPY (t, max-> name); strcpy (max-> name, p-> name); strcpy (p-> name, t); / * Switch the name in the front and rear nodes, make it match with SQL score * / Fen = max-> cyuyan; max-> cyuyan = p-> cyuyan; p-> cyuyan = fen; / * exchange the C grade in the front and rear nodes, make it matching the SQL score * / Fen = max-> vbyuyan; max-> vbyuyan = p-> vbyuyan; p-> vbyuyan = fen; / * exchange VB scores in the front and rear nodes, match the SQL score * /}} P = Head; Max = Head; }print2311 (hEAD); BREAK; DEFAULT: Printf ("Enter an error, please try again! / n");} return (0);} / * ================================================================================================================================================================ ====================================================== * // * ============================================================================================================================================================================================================= ===================================================== * / int menu2311 (K ) / * function menu2311, functions: menu selection interface * / {int i; printf ( "/ t / t / t / t test scores management system / n"); printf ( "/ t / t / t author: Xinjie Class: Information E3 student number: 24 / n "); for (i = 0; i <80; i ) Printf (" * "); Printf (" 1 Enter student data / T / T2 from file transfer Data / T / T / T3 query students 'results / N "); Printf (" 4 Delete Student Data / T / T5 Additional Information / T / T6 Display Students' Scores / N "); Printf ("7 Statistian Score / T / T / T8 Save Input Information / T / T / T9 Sort / N"); / * Menu Select Interface * / for (i = 0; I <80; I ) Printf ("*"); Printf ("Welcome to the grade management system, please select the action you want (select (0) exit):"); scanf ("% d", & k); / * Select operation * / GetChar (); Return (K); / * ================================================================================================================================================================ ====================================================== * // * ============================================================================================================================================================================================================= ===================================================== * / main () / * Main function main, function: By calling Creat, Search, Del, Add, Print, Stostistics, Save, Taxis and other functions, students to realize students' performance Query system function * / {score * head = 0, * STU = 0; While (1 ) {k = menu2311 (k); Switch (k) / * Implement function with Switch statement * / {case 1: head = CREAT2311 (); break; / * call Creation Link list function * / case 2: head = loading2311 HEAD; BREAK; / * From the file transferred record function * / case 3: head = search2311 (head; / * call grade query function * / case 4: head = DEL2311 (head); break; / * call Delete student data function * / case 5: head = add2311 (head, stu); break; / * call additional student data function * / case 6: print2311 (head); break; / * call display student data function * / cas 7 : Statistics2311 (HEAD); BREAK; / * Call statistical function * / case 8: save2311 (head); break; / * call save function * / case 9: Taxis2311 (head); break; / * Call Sort Function * / Case 0: EXIT (0); / * Exit the system, return to the main interface * / default: Printf ("Enter an error, please try again! / N");}}}