[c language] student award information collection and management system
1, Main function point requirements:
1. Basic information:
(1) Basic information of students: college, major, grade, student number and name
(2) Award information:
a. Time of Award (year, month, day)
b. Competition name
c. Award level (e.g. national first prize; Provincial Second Prize)
d. Instructor
e. Award Department
2. Design the main menu to realize user interaction
(1) Student role
a. Add function: students can add new award information
For example, enter:
School of computer engineering, major in software engineering, 2015 grade, 2015000000001, Zhang San, 20181222, national undergraduate software design competition, national first prize, teacher Li Si, society of higher education
Screen printing:
Enter 1 piece of award information!
b. Browsing function: students can browse the existing award-winning information, sorted by time
For example, if you enter another award information now:
College of mechanical engineering, major in industrial design, grade 2016, 201600000001, Wang Wu, 20180108, Guangdong industrial design competition, provincial second prize, teacher Lin Liang, Guangdong industrial design society
After selecting the browse function, the screen will print:
1. College of mechanical engineering, major in industrial design, grade 2016, 201600000001, Wang Wu, 20180108, Guangdong industrial design competition, provincial second prize, teacher Lin Liang, Guangdong industrial design society, unaudited
2. School of computer engineering, major in software engineering, 2015 grade, 2015000000001, Zhang San, 20181222, national undergraduate software design competition, national first prize, teacher Li Si, society of higher education, unaudited
There are 2 pieces of award-winning information!
c. Search function: students can search the existing award information in any field and sort it by time
For example, enter: computer
Screen printing:
School of computer engineering, major in software engineering, 2015 grade, 2015000000001, Zhang San, 20181222, national undergraduate software design competition, national first prize, teacher Li Si, society of higher education, unaudited
A total of 1 award-winning information was searched!
d. Delete function: students can delete the existing award information
For example, enter: 2 (2 represents the serial number of the award information)
Screen printing:
1 award information has been deleted!
e. Modification function: students can modify any field of any existing award-winning information
For example, enter: 1
Screen printing: please indicate the field of the record you want to modify:
- Award time 2 Competition name 3 Award level 4 Instructor 5 Award Department
Input: 3
Then the screen will print: Please enter a new award level:
Input: Provincial Third Prize
Screen printing:
1 piece of award-winning information has been modified!
1. College of mechanical engineering, major in industrial design, grade 2016, 201600000001, Wang Wu, 20180108, Guangdong industrial design competition, provincial third prize, teacher Lin Liang, Guangdong industrial design society, unaudited
(2) Role of grade counselor
a. Browsing function: grade counselors can browse the existing award-winning information, sorted by time (consistent with the browsing function of students)
b. Review function: grade counselors can review any award-winning information
For example, enter: 1 (to review the first award information)
Screen printing:
1. College of mechanical engineering, major in industrial design, grade 2016, 201600000001, Wang Wu, 20180108, Guangdong industrial design competition, provincial third prize, teacher Lin Liang, Guangdong industrial design society, has been reviewed
Function not implemented: sort according to time and delete the function from txt file
Since the addition function is completed with a pointer, there is a small problem that the newly added information will be overwritten, so it will not be added
#include<stdio.h> #include<string.h> #include<windows.h> const int N=3; //Students: Student ID, name, grade, major, College /*Award time (prtime), competition name (prname), award grade (prgrade), instructor (prteacher), e. award Department (prplace)*/ struct student{ char id[100]; char name[100]; char grade[100]; char major[100]; char college[100]; char prtime[100]; char prname[100]; char prgrade[100]; char prteacher[100]; char prplace[100]; char check[100]; }; //Function declaration void firstMenu(); void studentMenu(); //Student function page menu void teacherMenu();//Teacher function page menu void addStudent(student *stu);//Add student award information function void delStudent(student stu[]); //Delete student award information function void modifyStudent(student stu[]); //Modify student award information void watchStudent(student stu[]); //Browse the existing award-winning information. (counselors also have this function) void searchStudent(student stu[]); //Students can search for information about awards they already have void checkStudent(student stu[]); //Counselor function: review students' award-winning information void save(); //Export to file void load(); struct student stu[N]={0}; int count=0; int main(){ system("color F0"); while(true){ firstMenu(); int i; scanf("%d",&i); switch(i){ case 1:teacherMenu();break; case 2:studentMenu();break; case 3:exit(0);break; default:printf("Input format error, need to re-enter."); }} } void firstMenu(){ printf("**************Welcome to the student information award system********************\n"); printf("If you are a teacher, please enter 1"); printf("If you are a student, please enter 2\n"); printf("Please enter 3 to end the program\n"); printf("***********************************************************************\n"); printf("Please enter your choice:"); int i; scanf("%d",&i); switch(i){ case 1:teacherMenu();break; case 2:studentMenu();break; case 3:exit(0);break; default:printf("Input format error, need to re-enter."); } } void studentMenu(){ while(true){ printf("***********************************************************************\n"); printf("Enter 1 to enter the function of adding information\n"); printf("Enter 2 to enter the view information function\n"); printf("Enter 3 to enter the function of deleting information\n"); printf("Enter 4 to enter the function of modifying information\n"); printf("Enter 5 to enter the search information function\n"); printf("Enter 6 to return to the original page.\n");; printf("Enter 9 to end the program\n"); printf("If you are not a student, enter 7 to enter the counselor function.\n"); printf("***********************************************************************\n"); printf("Please enter your choice:"); int j; scanf("%d",&j); switch(j){ case 1:addStudent(stu);break; case 2:watchStudent(stu);break; case 3:delStudent(stu);break; case 4:modifyStudent(stu);break; case 5:searchStudent(stu);break; case 6:firstMenu();break; case 7:teacherMenu();break; case 8:exit(0); default:printf("Input format error, need to re-enter.\n"); }} } void teacherMenu(){ while(true){ printf("***********************************************************************\n"); printf("Enter 1 to enter the browsing function\n"); printf("Enter 2 to enter the review function\n"); printf("Enter 3 to return to the original menu.\n"); printf("If you are not a teacher, enter 4 to enter the student function.\n"); printf("***********************************************************************\n"); printf("Please enter your choice:\n"); int k; scanf("%d",&k); switch(k){ case 1:watchStudent(stu);break; case 2:checkStudent(stu);break; case 3:firstMenu();break; case 4:studentMenu();break; }} } /* Add function: addstudent (studnt * stu) function, you can choose to add several people, and then you can directly enter the student information to be added to the system. */ void addStudent(student *stu){ //Add function: students can add new award information int i,j,n; struct student *p; p=stu; p+=count; printf("***********************************************************************\n"); printf("Please enter the number of students to add:"); scanf("%d",&n); for(i=0;i<n;i++){ printf("Please enter the student information you want to add:\n"); printf("Please enter the student number you want to add:\n"); scanf("%s",p->id); printf("Please enter the name of the student you want to add:\n"); scanf("%s",p->name); printf("Please enter the grade you want to add:\n"); scanf("%s",p->grade); printf("Please enter the student major you want to add:\n"); scanf("%s",p->major); printf("Please enter the student college you want to add:\n"); scanf("%s",p->college); printf("Please enter the winning time of the student you want to add:\n"); scanf("%s",p->prtime); printf("Please enter the award name of the student you want to add:\n"); scanf("%s",p->prname); printf("Please enter the award level of the student you want to add:\n"); scanf("%s",p->prgrade); printf("Please enter the student tutor you want to add:\n"); scanf("%s",p->prteacher); printf("Please enter the awarding Department of the student you want to add:\n"); scanf("%s",p->prplace); p++; count++; save(); } printf("Information added.\n"); printf("***********************************************************************\n"); } //Export to file function void save(){ FILE *fp=NULL; char filename[100]; printf("Enter file path:"); scanf("%s",&filename); fp=fopen(filename,"wb");//Open the file in binary mode int i; for(i=0;i<count;i++){ fprintf(fp,"%-10s%-10s%-10s%-10s%-15s%-20s%-25s%-15s%-18s%-18s%-10s\n",&stu[i].id,&stu[i].name,&stu[i].grade,&stu[i].major,&stu[i].college,&stu[i].prtime,&stu[i].prname,&stu[i].prgrade,&stu[i].prteacher,&stu[i].prplace); fflush(stdin);//Clear file buffer } fclose(fp); //Close file printf("success"); } /*Import to file function*/ void load(){ FILE *fp=NULL; char filename[100]; //The method noted below is also feasible, but it may have to be changed. So I commented it out. /*printf("Input file path: "; scanf("%s",&filename); fp=fopen(filename,"rb");//r Read as for(i=0;i<count;i++){ fprintf(fp,"%-10s%-10s%-10s%-10s%-15s%-20s%-25s%-15s%-18s%-18s%-10s\n",&stu[N].id,&stu[N].name,&stu[N].grade,&stu[N].major,&stu[N].college,&stu[N].prtime,&stu[N].prname,&stu[N].prgrade,&stu[N].prteacher,&stu[i].prplace); fflush(stdin);//Clear file buffer }*/ int i; if((fp=fopen("03.txt","rb"))==NULL){ printf("Cannot open."); for(i=0;i<10;i++){ fread(&stu[i],sizeof(struct student),1,fp); fclose(fp); } } } /*Delete information: deleStudent(stu) function Enter the student number of the student information to be deleted and find the corresponding message for confirmation. After confirmation, you can directly delete the student's information.*/ void delStudent(student stu[]){ //Delete student award information printf("***********************************************************************\n"); printf("Here is the function of deleting student information:"); char id2[100]; int i,j; printf("Please enter the student number of the student you want to delete:"); scanf("%s",&id2); for(i=0;i<3;i++){ if(strcmp(stu[i].id,id2)==0){ for(j=i;j<3;j++){ stu[j-1]=stu[j]; printf("Delete succeeded!"); }/*There are N students, and the score array elements are from 0 to N-1. To delete a student's grade, you need to judge whether the student exists. If so, the subsequent student's grade will move forward*/ } } } /*Modify student information: modifyStudent(stu) function Select the information to be modified, select the corresponding modification item, and enter the information to be modified. For example, if you need to modify the name, enter the option to modify the name, and then enter the name to be modified.*/ void modifyStudent(student stu[]){ //Modify student award information printf("***********************************************************************\n"); printf("Here is the function of modifying student information:"); int i,j; int choose; char id2[100]; printf("Please enter the student ID you need to modify:\n"); scanf("%s",&id2); for(i=0;i<3;i++){ if(strcmp(stu[i].id,id2)==0){ printf("Here are the student information you need to modify:\n"); printf("Student number full name grade major college Award time Competition name Award level Instructor Award Department\n"); printf("*********************************************************************************************************************************************************\n"); printf("%-10s%-10s%-10s%-10s%-15s%-20s%-25s%-15s%-18s%-18s%-10s\n",&stu[i].id,&stu[i].name,&stu[i].grade,&stu[i].major,&stu[i].college,&stu[i].prtime,&stu[i].prname,&stu[i].prgrade,&stu[i].prteacher,&stu[i].prplace,&stu[i].check); j=i; printf("Please enter 1 to modify student ID\n"); printf("Please enter 2 to modify the student name\n"); printf("Please enter 3 to modify student grade\n"); printf("Please enter 4 to modify student major\n"); printf("Please enter 5 to modify the student college\n"); printf("Please enter 6 to modify the student award time\n"); printf("Please enter 7 to modify the student award name\n"); printf("Please enter 8 to modify the student award level\n"); printf("To modify the student's instructor, please enter 9\n"); printf("Please enter 10 to modify the student's award location\n"); printf("Please enter your choice:"); scanf("%d",&choose); switch(choose){ case 1:printf("Enter the student number to be modified into:"); scanf("%s",&stu[j].id);break; case 2:printf("Enter the name of the student you want to change to:"); scanf("%s",&stu[j].name);break; case 3:printf("Enter the student grade to be modified to:"); scanf("%s",&stu[j].grade);break; case 4:printf("Enter the student major to be modified:"); scanf("%s",&stu[j].major);break; case 5:printf("Enter the student college to be modified to:"); scanf("%s",&stu[j].college);break; case 6:printf("Enter the student award time to be modified to:"); scanf("%s",&stu[j].prtime);break; case 7:printf("Enter the name of the student competition to be modified:"); scanf("%s",&stu[j].prname);break; case 8:printf("Enter the award grade of the student to be modified to:"); scanf("%s",&stu[j].prgrade);break; case 9:printf("Enter the student instructor to be modified to:"); scanf("%s",&stu[j].prteacher);break; case 10:printf("Enter the student award location to be modified to:"); scanf("%s",&stu[j].prplace);break; default:printf("Input error.");break; }//switch save(); printf("Modification succeeded!"); }} } /*View information: the watchStudent(stu) function circularly outputs the existing student information in the system for easy viewing.*/ void watchStudent(student stu[]){ //Browse the existing award-winning information. (counselors also have this function) printf("Here is the function of viewing student information:\n"); struct student *p; printf("Student number full name grade major college Award time Competition name Award level Instructor Award Department\n"); printf("*********************************************************************************************************************************************************\n"); for(p=stu;p<stu+3;p++){ printf("%-10s%-10s%-10s%-10s%-15s%-20s%-25s%-15s%-18s%-18s%-10s\n",p->id,p->name,p->grade,p->major,p->college,p->prtime,p->prname,p->prgrade,p->prteacher,p->prplace,p->check); } } /*Find information: searchStudent(stu) function You can find the student information according to the student number or name of the student, and compare the input student information with the student information owned by the original system through the strcmp function. If the comparison is successful, you can directly output all the information of the student.*/ void searchStudent(student stu[]){ //Students can search for information about awards they already have load(); int i,j; int count=0; char id2[100]; char name2[100]; printf("Here is the function of querying student information. For student number query, please press 1:"); printf("Here is the function of querying student information. For name query, please press 2:"); scanf("%d",&i); if(i==1){ printf("Please enter the student number you need to query:"); scanf("%s",id2); for(j=0;j<4;j++){ if(strcmp(stu[j].id,id2)==0){ printf("Search succeeded!\n"); printf("The student's information is:\n"); printf("Student number full name grade major college Award time Competition name Award level Instructor Award Department\n"); printf("%-10s%-10s%-10s%-10s%-15s%-20s%-25s%-15s%-18s%-18s%-10s\n",&stu[j].id,&stu[j].name,&stu[j].grade,&stu[j].major,&stu[j].college,&stu[j].prtime,&stu[j].prname,&stu[j].prgrade,&stu[j].prteacher,&stu[j].prplace,&stu[j].check); count++;}}if(count==0){printf("Can't find.");} } if(i==2){ printf("Please enter the name of the student you need to query:"); scanf("%s",name2); for(j=0;j<4;j++){ if(strcmp(stu[j].name,name2)==0){ printf("Search succeeded!\n"); printf("The student's information is:\n"); printf("Student number full name grade major college Award time Competition name Award level Instructor Award Department\n"); printf("%-10s%-10s%-10s%-10s%-15s%-20s%-25s%-15s%-18s%-18s%-10s\n",&stu[j].id,&stu[j].name,&stu[j].grade,&stu[j].major,&stu[j].college,&stu[j].prtime,&stu[j].prname,&stu[j].prgrade,&stu[j].prteacher,&stu[j].prplace,&stu[j].check); count++;}} if(count==0){printf("Can't find.");}} } /*Audit function: checkStuent(stu) function, You need to find the information of the student to be audited, enter his student number, and directly enter 'audited' after checking that there is no problem. Principle: in the above structure, define char check[20] for standby. At first, do not assign a value. When the counselor selects the audit function, directly use the above modification function to change the assignment of the original check array without assignment. */ void checkStudent(student stu[]){ //Counselor function: review students' award-winning information char id2[100]; char check2[100]; int j,count=0; int choose; printf("***********************************************************************\n"); printf("Here is the Counselor's function of reviewing student information:\n"); printf("Please enter the student number you need to check:"); scanf("%s",&id2); for(j=0;j<3;j++){ if(strcmp(stu[j].id,id2)==0){ printf("Search succeeded!\n"); printf("The student's information is:\n"); printf("Student number full name grade major college Award time Competition name Award level Instructor Award Department\n"); printf("%-10s%-10s%-10s%-10s%-15s%-20s%-25s%-15s%-18s%-18s%-10s\n",&stu[j].id,&stu[j].name,&stu[j].grade,&stu[j].major,&stu[j].college,&stu[j].prtime,&stu[j].prname,&stu[j].prgrade,&stu[j].prteacher,&stu[j].prplace,&stu[j].check); count++; printf("Is the student's information incorrect? If there is any error, press 1 to enter the modification page. If there is no error, press 2."); scanf("%d",&choose); switch(choose){ case 1:modifyStudent(stu);break; case 2:printf("Make sure you're right! Please enter approved."); scanf("%s",&stu[j].check); }//if }//for }//switch }
Operation screenshot:
Modify student information:
Add student information function:
Find student information:
View student information:
Counselor review function:
Add to txt:
Screenshot of file and txt:
flow chart: