Title Requirements:
2. Student comprehensive evaluation system
The information of each student is: student number, name, gender, contact number, C language, higher mathematics and foreign language, average test score, test ranking, students' mutual score, moral score, teacher's score, total score of comprehensive evaluation and comprehensive evaluation ranking. The average test score, students' mutual score, moral score and teachers' score account for 60%, 10%, 10% and 20% of the total score of the comprehensive evaluation respectively.
A. Student information processing
(1) Input student information, student number, name, gender and contact number, and store them in the file in the order of small to large according to the student number.
Tip: student information can be input into the array first, and then written to the file after sorting.
(2) Insert (modify) student information:
Tip: first input the information of the student to be inserted, then open the source file and create a new file, and merge the source file and the input information into the new file (keep the order according to the student number). If there is a student, replace the source content with the new record content,
(3) Delete classmate information:
Prompt: enter the student number to be deleted, read out the student information, and ask for confirmation to decide whether to delete it. Write the deleted information to the file.
(4) Browse student information:
Tip: open the file and display the student information of the file.
B. Student data processing:
(1) Enter the student scores according to the test subjects, calculate the test scores according to the formula: test scores = (C language + Advanced Mathematics + foreign language) / 3, and calculate the test ranking. Tips: first read the student information into the array, then enter the scores of each subject according to the prompts, calculate the test scores, calculate the ranking, and finally write the student records into a file.
(2) Input students' evaluation data and calculate the total score and ranking of comprehensive evaluation.
Tip: total score of comprehensive evaluation = (test score) * 0.6 + (students' mutual score) * 0.1 + moral score * 0.1 + teacher's score * 0.2.
(3) Student data management
Tip: enter the student number, read out and display the student information, enter new data, and write the modified information into the file
(4) Student data query:
Prompt: enter student number or other information, that is, read out all data information and display it.
C. Student comprehensive information output
Tip: output student information to the screen.
Background: Xiaobai fought alone from 3:00 p.m. to 11:00 p.m., which may not be well written in many places. O(∩ ∩) O ha ha ~, record it
code:
#include<stdio.h> #include<stdlib.h> void mainMenu();//Main menu void studentInformationInput();//Student information input void Input();//Student information input void rankOfExam();//Ranking of examination results void rankOfFinal();//Ranking of comprehensive evaluation void input0returnMainMenu();//Press key 0 to return to the main menu void studentInformationSearch();//Student information search void studentInformationDelete();//Student information deletion void studentInformationAdd();//Student information increase void studentInformationPrint();//Student information output void fileOperation();//File operation void fileInput();//Save data to file void filePrint();//Data output in file typedef struct student_data//Student information { long long number;//The student number is directly stored as an ll type data char name[10];//Names are stored in an array of char types char sex[10]; char phoneNumber[20];//The telephone number is also stored in an ll type data (after all, the student number and telephone number are stored in 11 digits, which is enough) float gradeOfC;//C points float gradeOfMath;//Mathematical score float gradeOfEnglish;//English score float average;//average int rankOfExam;//Ranking by average score float gradeOfClassmate;//Students grade each other float gradeOfMorality;//Moral score float gradeOfTeacher;//Teacher score float gradeOfFinal;//Comprehensive score int rankOfFinal;//Ranking by comprehensive score struct student_data *next;//Pointer to the next student node }SD; SD *head=NULL;//Create header pointer void input0returnMainMenu() { int choose; scanf("%d",&choose); while(choose!=0) { printf("Your input is incorrect, please re-enter:"); scanf("%d",&choose); } if(choose==0)mainMenu(); } void rankOfExam() { SD *p=head; float temp[100]; int count=1; while(p!=NULL) { temp[count]=p->average; count++; p=p->next; } count--; for(int i =count-1;i>=1;i--)//Bubble sort from large to small for(int j =1;j<=i;j++) if(temp[j]<temp[j+1]){float tempP=temp[j];temp[j]=temp[j+1];temp[j+1]=tempP;} SD *p1=head; while(p1!=NULL)//The for loop is nested inside. This is an array traversal for each node. If the scores are equal, the ranking is recorded and the for loop is ended immediately { for(int i =1;i<=count;i++) if(p1->average==temp[i]) { p1->rankOfExam=i; break; } p1=p1->next; } } void rankOfFinal() { SD *p=head; float temp[100]; int count=1; while(p!=NULL) { temp[count]=p->gradeOfFinal; count++; p=p->next; } count--; for(int i =count-1;i>=1;i--)//Bubble sort from large to small for(int j =1;j<=i;j++) if(temp[j]<temp[j+1]){float tempP=temp[j];temp[j]=temp[j+1];temp[j+1]=tempP;} SD *p1=head; while(p1!=NULL)//The for loop is nested inside. This is an array traversal for each node. If the scores are equal, the ranking is recorded and the for loop is ended immediately { for(int i =1;i<=count;i++) if(p1->gradeOfFinal==temp[i]) { p1->rankOfFinal=i; break; } p1=p1->next; } } void mainMenu()//Master page function { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) printf("\n\n\n\n\n"); printf("\t\t\t-------------Welcome to the student comprehensive evaluation system---------------\n" "\t\t\t-------------1-Student information input-----------------------\n" "\t\t\t-------------2-Student information deletion-----------------------\n" "\t\t\t-------------3-Student information increase-----------------------\n" "\t\t\t-------------4-Student information search-----------------------\n" "\t\t\t-------------5-Student information output-----------------------\n" "\t\t\t-------------6-Operation file--------------------------\n" "\t\t\t-------------0-Exit the system--------------------------\n\n" "\t\t\t-------------Please enter a numeric number to select------------------\n"); int choose; scanf("%d",&choose); while(choose!=0&&choose!=1&&choose!=2&&choose!=3&&choose!=4&&choose!=5&&choose!=6) { printf("Your input is incorrect, please re-enter:\n"); scanf("%d",&choose); } switch(choose) { case 1:studentInformationInput();break; case 2:studentInformationDelete();break; case 3:studentInformationAdd();break; case 4:studentInformationSearch();break; case 5:studentInformationPrint();break; case 6:fileOperation();break; case 0:printf("The system has been exited. Thank you for your use!\n");exit(0); } } void studentInformationInput()//Student information input function { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) printf("\n\n\n\n\n"); printf("\t\t\t-------------Welcome to enter student information----------------------\n" "\t\t\t-------------1-Student information input-----------------------\n" "\t\t\t-------------0-Return to main menu----------------------------\n\n" "\t\t\t-------------Please enter a numeric number to select------------------\n" "\t\t\t-------------------------------\n"); int choose; scanf("%d",&choose); while(choose!=0&&choose!=1) { printf("Your input is incorrect, please re-enter:\n"); scanf("%d",&choose); } switch(choose) { case 1:Input();break; case 0:mainMenu(); } } void Input() { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) if(head!=NULL) { printf("You have entered student information here before. If you want to modify student information, please go to other modules and enter 0 to return to the main menu\n"); input0returnMainMenu(); } SD *s0=(SD*)malloc(sizeof(SD)); head=s0; printf("Please enter the student's student number. If you end your entry, please enter 0 in the student number field\n" "The size of student numbers must be arranged from small to large, otherwise you may want to execute the student information you have not entered in the student information addition in the main menu\n"); scanf("%lld",&s0->number); printf("\n"); while(s0->number!=0) { printf("Please enter the student's name:");scanf("%s",s0->name);; printf("Please enter the gender of the student:");scanf("%s",s0->sex); printf("Please enter the student's phone number:");scanf("%s",s0->phoneNumber); printf("Please enter the student's C Language scores");scanf("%f",&s0->gradeOfC); printf("Please enter the student's high score:");scanf("%f",&s0->gradeOfMath); printf("Please enter the student's English score:");scanf("%f",&s0->gradeOfEnglish); s0->average=(s0->gradeOfC+s0->gradeOfMath+s0->gradeOfEnglish)/3.0;//Calculate average score printf("Please enter the student's peer rating:");scanf("%f",&s0->gradeOfClassmate); printf("Please enter the student's moral score:");scanf("%f",&s0->gradeOfMorality); printf("Please enter the teacher score of the students:");scanf("%f",&s0->gradeOfTeacher); s0->gradeOfFinal=s0->average*0.6+s0->gradeOfClassmate*0.1+s0->gradeOfMorality*0.1+s0->gradeOfTeacher*0.2;//Calculate comprehensive measurement score printf("The information of this student has been entered"); SD *s1; s1=s0; s0=(SD*)malloc(sizeof(SD)); s1->next=s0; printf("Please enter the student number:");scanf("%lld",&s0->number); while(s0->number<=s1->number&&s0->number!=0){printf("You have entered a student number equal to or smaller than the previous student number, which does not comply with the regulations. Please re-enter:");scanf("%lld",&s0->number);} if(s0->number==0)s1->next=NULL; } rankOfExam(); rankOfFinal(); printf("Because you entered 0 in the student number, the system thinks your input is complete. Please type 0 to return to the main menu"); input0returnMainMenu(); } void studentInformationSearch()//Student information search function { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) rankOfExam();//Two ranking information should be updated before looking for information rankOfFinal();// int num; printf("Please enter the student number you want to find:");scanf("%lld",&num); SD *p=head; while(p!=NULL) { if(p->number==num)break; p=p->next; } if(p==NULL){printf("If there is no such person, please press 0 to return to the main menu");input0returnMainMenu();} printf("Student number Name Gender contact number C Language scores high scores English scores average scores test scores ranking Students grade each other Grade of moral achievements by teachers Comprehensive test score ranking\n"); printf("%-11lld%-7s%-5s%-12s",p->number,p->name,p->sex,p->phoneNumber); printf("%-11.2f%-9.2f%-9.2f%-9.2f%-13d",p->gradeOfC,p->gradeOfMath,p->gradeOfEnglish,p->average,p->rankOfExam); printf("%-11.2f%-9.2f%-13.2f%-9.2f%-12d\n",p->gradeOfClassmate,p->gradeOfMorality,p->gradeOfTeacher,p->gradeOfFinal,p->rankOfFinal); printf("This is the student's information. You can press 0 to return to the main menu");input0returnMainMenu(); } void studentInformationDelete()//Student information deletion function { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) if(head==NULL) { printf("You haven't entered student information yet. Please enter 0 to return to the student information input page"); int choose; scanf("%d",&choose); while(choose!=0) { printf("Wrong input! Please re-enter"); scanf("%d",&choose); } if(choose==0)studentInformationInput(); } printf("If you want to go back to the main menu, enter 0,Delete student information input 1"); int choose; scanf("%d",&choose); while(choose!=0&&choose!=1) { printf("Wrong input! Please re-enter"); scanf("%d",&choose); } if(choose==0)studentInformationInput(); int num; printf("Please enter the student number of the student you want to delete:"); scanf("%lld",&num); SD *p1,*p2; p1=head; while(num!=p1->number&&p1->next!=NULL)//When this node is not found and p1 is not the tail node after the loop, p2 is the last node of p1 after each loop { p2=p1;p1=p1->next; } if(num==p1->number) { if(p1==head){head=p1->next;} else { p2->next=p1->next;//All contain next, so as to really operate the linked list } printf("This student information has been deleted. Please enter 0 to return to the main menu"); input0returnMainMenu(); } else { printf("If there is no such person, press 0 to re-enter"); int choose; scanf("%d",&choose); while(choose!=0) { printf("Wrong input! Please re-enter"); scanf("%d",&choose); } if(choose==0)studentInformationDelete(); } } void studentInformationAdd()//Student information increase function { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) int num; printf("Please enter the student number you want to add:"); scanf("%lld",&num); SD *p1,*p2; p1=head; while(p1!=NULL) { if(p1->number==num) { printf("Hello, the student number you entered already exists. Please enter 0 and re-enter"); int choose; scanf("%d",&choose); while(choose!=0) { printf("The input is not 0, please re-enter"); scanf("%d",&choose); } if(choose==0);studentInformationAdd(); } p1=p1->next; } SD *s0=(SD*)malloc(sizeof(SD)); if(head==NULL){head=s0;s0->next=NULL;}//First, if the head node does not exist, create a node directly else//When the head node exists { p1=head; while(p1->number<=num&&p1->next!=NULL)//The student number of p1 is less than or equal to the entered student number and is not p1, not the tail node; There are two conditions for cycle stop: 1 is that the student number of p1 is greater than the input student number, and 2 is that p is the tail node { p2=p1;p1=p1->next; } if(p1->number>num)//In the first case, insert directly { if(p1==head){s0->next=head;head=s0;} else{p2->next=s0;s0->next=p1;} } else{p1->next=s0;s0->next=NULL;}//The second case is tail insertion } s0->number=num; printf("Please enter the student's name:");scanf("%s",s0->name);; printf("Please enter the gender of the student:");scanf("%s",s0->sex); printf("Please enter the student's phone number:");scanf("%s",s0->phoneNumber); printf("Please enter the student's C Language scores");scanf("%f",&s0->gradeOfC); printf("Please enter the student's high score:");scanf("%f",&s0->gradeOfMath); printf("Please enter the student's English score:");scanf("%f",&s0->gradeOfEnglish); s0->average=(s0->gradeOfC+s0->gradeOfMath+s0->gradeOfEnglish)/3.0;//Calculate average score printf("Please enter the student's peer rating:");scanf("%f",&s0->gradeOfClassmate); printf("Please enter the student's moral score:");scanf("%f",&s0->gradeOfMorality); printf("Please enter the teacher score of the students:");scanf("%f",&s0->gradeOfTeacher); s0->gradeOfFinal=s0->average*0.6+s0->gradeOfClassmate*0.1+s0->gradeOfMorality*0.1+s0->gradeOfTeacher*0.2;//Calculate comprehensive measurement score printf("The information of this student has been entered. You can enter 0 to return to the main menu");input0returnMainMenu(); } void studentInformationPrint()//Student information printing function { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) printf("\n\n\n\n\n"); rankOfExam();//Two ranking information should be updated before printing rankOfFinal(); printf("Student number Name Gender contact number C Language scores high scores English scores average scores test scores ranking Students grade each other Grade of moral achievements by teachers Comprehensive test score ranking\n"); SD *p=head; while(p!=NULL) { printf("%-11lld%-7s%-5s%-12s",p->number,p->name,p->sex,p->phoneNumber); printf("%-11.2f%-9.2f%-9.2f%-9.2f%-13d",p->gradeOfC,p->gradeOfMath,p->gradeOfEnglish,p->average,p->rankOfExam); printf("%-11.2f%-9.2f%-13.2f%-9.2f%-12d\n",p->gradeOfClassmate,p->gradeOfMorality,p->gradeOfTeacher,p->gradeOfFinal,p->rankOfFinal); p=p->next; } printf("If you want to go back to the main menu, enter 0"); input0returnMainMenu(); } void fileOperation() { system("cls"); system("color 7A");//Print green words on a white background system("date/t");//Print system date (note date/t) system("time/t");//Print system time (specific) rankOfExam();//Two ranking information should be updated before file operation rankOfFinal();// if(head==NULL){printf("The header node is empty. It seems that no data has been entered. It is recommended that you press 0 to return to the main menu and enter data");input0returnMainMenu();} printf("If you want to save the data to a file, enter 1\n"); printf("If you want to display the data in the file, enter 2\n"); printf("If you want to return to the main menu, enter 0\n"); int choose; scanf("%d",&choose); while(choose!=0&&choose!=1&&choose!=2) { printf("Illegal input, please re-enter"); scanf("%d",&choose); } switch(choose) { case 1:fileInput();break; case 2:filePrint();break; case 0:mainMenu(); } } void fileInput() { FILE *fp; fp=fopen("C:\\Users\\FX\\Desktop\\data.txt","w+"); SD *p=head; fprintf(fp,"Student number Name Gender contact number C Language scores high scores English scores average scores test scores ranking Students grade each other Grade of moral achievements by teachers Comprehensive test score ranking\n"); while(p!=NULL) { fprintf(fp,"%-11lld%-7s%-5s%-12s",p->number,p->name,p->sex,p->phoneNumber); fprintf(fp,"%-11.2f%-9.2f%-9.2f%-9.2f%-13d",p->gradeOfC,p->gradeOfMath,p->gradeOfEnglish,p->average,p->rankOfExam); fprintf(fp,"%-11.2f%-9.2f%-13.2f%-9.2f%-12d\n",p->gradeOfClassmate,p->gradeOfMorality,p->gradeOfTeacher,p->gradeOfFinal,p->rankOfFinal); p = p->next; } fclose(fp); printf("You have finished saving. If you want to return to the main menu, type 1. If you want to return to the previous level, type 2"); int choose;scanf("%d",&choose); while(choose!=1&&choose!=2) { printf("Illegal input, please re-enter"); scanf("%d",&choose); } switch(choose) { case 1:mainMenu();break; case 2:fileOperation(); } } void filePrint() { FILE *fp; fp=fopen("C:\\Users\\FX\\Desktop\\data.txt","r"); char s[1000]; while(fgets(s,1000,fp)!=NULL) { printf("%s\n",s); } fclose(fp); printf("You have finished reading. If you want to return to the main menu, type 1. If you want to return to the previous level, type 2"); int choose;scanf("%d",&choose); while(choose!=1&&choose!=2) { printf("Illegal input, please re-enter"); scanf("%d",&choose); } switch(choose) { case 1:mainMenu();break; case 2:fileOperation(); } } int main() { setbuf(stdout,NULL); system("pause");//Pause and buffer mainMenu();//Call master page }