<>C Course design of language programming

<> Student achievement management system
#include<stdio.h> #include<string.h> #include<stdlib.h> #include<windows.h>
#define M 1000 //*********** structural morphology ***** struct student{ char name[30];// Student name char
num[30];// Student number int zy;// major int bj;// class int math;// Mathematics achievement int yy;// English achievement int
dl;// Introduction to professional courses int cyy;//C language achievement int ty;// Sports performance int s;// Total score double pj;// average };
//¥¥¥¥¥¥¥ Start function declaration ¥¥¥¥¥¥¥¥ void fileread(struct student stu[M]);//* Read file function void
filesave(struct student stu[M]);//* Save file function void input(struct student
stu[M]);//**** Input data function void output(struct student stu[M]);//*** Output function void
del(struct student stu[M]);//****** Delete student information function (1 ,2) void gai(struct student
stu[M]);//****** Change the score function void chakang(struct student stu[M]);//** The function of querying the information of students' grades void
name_(struct student stu[M]);//**** Use the student's name to delete their information 1 void num_(struct student
stu[M]);//***** Use student ID to delete their information 2 void order(struct student stu[M]);//**** Sorting function
//¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥¥ int count=0;// Enter the number of student achievement information , At first it was zero struct student t;
// this t Yes order Used for sorting int main() { int sum=0,xuan;//xuan At the beginning, enter the interface to select , system("mode
con: cols=369 lines=3690"); // Control compiler height and width struct student stu[M];
//********** Code running interface ********* printf("\t\t\t\t\t\t Welcome to use the student achievement management information system \n"); do{
printf("\t\t\t\t\t -------------------------------------------\n");
printf("\t\t\t\t\t\t *** Student achievement information management system ***\n"); printf("\t\t\t\t\t\t\t
***************\n"); printf("\t\t\t\t\t\t\t 1, Input student information \n");
printf("\t\t\t\t\t\t\t 2, Browse student information \n"); printf("\t\t\t\t\t\t\t 3, View student information \n");
printf("\t\t\t\t\t\t\t 4, Revise student grades \n"); printf("\t\t\t\t\t\t\t 5, Delete student information \n");
printf("\t\t\t\t\t\t\t 6, Student information ranking \n"); printf("\t\t\t\t\t\t\t 7, Read file information \n");
// Read from file printf("\t\t\t\t\t\t\t 8, Save to file \n"); // Save to file printf("\t\t\t\t\t\t\t
9, Exit the system \n"); printf("\t\t\t\t\t\t\t ***************\n"); printf("\t\t\t\t\t\t\t
Please enter your choice \n"); scanf("%d",&xuan); // Select function fflush(stdin); // Clear input buffer if
(xuan>9||xuan<=0) { sum++; if (sum>=8) { printf(" Too many input errors 8 second , The program will restart \n");
// By limiting incorrect input , Avoid a dead end system("pause"); // Program pause , Reselect system("cls"); // Clear screen statement } }
switch (xuan) // According to the choice , Call different functions to complete different tasks { case 1:input(stu);break; // input case
2:output(stu);break; // output case 3:chakang(stu);break; // query case
4:gai(stu);break; // modify case 5:del(stu);break; // delete case 6:order(stu);break;
// sort case 7:fileread(stu);break;// Read file data case 8:filesave(stu);break;// Save file data
case 9:printf(" Finished using , Please turn off the program \n");system("pause");break;
default:printf(" Invalid choice , Please re-enter \n");break; } }while (xuan!=9); printf(" The program ends
over\n"); return 0; } void filesave(struct student stu[M])//******* Save file function *****
{ int a=0; char b; FILE *fp; printf(" Please confirm whether the student information has been entered :'y' or 'n'?\n");
scanf("%c",&b); fflush(stdin);// Clear input buffer while(b!='y'&&b!='n') {
if(b!='y'&&b!='n') printf(" Input error , Reenter \n"); printf(" Please enter if you are sure 'y' or 'n'?\n");
scanf("%c",&b); fflush(stdin);// Clear input buffer } if(b=='y') {
if((fp=fopen("E:\123\ New folder ","wb"))==NULL) { printf(" File open error , The program could not proceed \n"); exit(0);
} for(a=0;a<count;a++) { fwrite(&stu[a],sizeof(struct student),1,fp); }
fclose(fp); if(count==0) printf(" No student achievement information , Can't save \n"); else printf(" The data has been saved ok\n");
} else return; } void fileread(struct student stu[M])//***** Read file function { int a=0;
char b; FILE *fp; system("cls");// Clear screen statement printf(" Please confirm whether the student information has been entered or stored :'y'or'n'?\n");
scanf("%c",&b); fflush(stdin);// Clear input buffer while(b!='y'&&b!='n') {
if(b!='y'&&b!='n') printf(" Input error , Reenter \n");
printf(" Please confirm whether the student information has been entered or stored :'y'or'n'?\n"); scanf("%c",&b); fflush(stdin);// Clear input buffer
} if(b=='y') { if((fp=fopen("E:\123\ New folder ","rb"))==NULL) {
printf(" File open error , The program cannot proceed \n"); exit(0); } fread(&stu[a],sizeof(struct
student),1,fp); count=0; count++; a++; while(fread(&stu[a],sizeof(struct
student),1,fp)) { a++; count++; } fclose(fp); printf(" Data read complete !!!\n");
system("cls");// Clear screen statement system("pause");// System restart , Select function (1~9) } else return; }
void input(struct student stu[M]) //**** Input function ***** { int len;
system("cls");// Clear screen statement printf(" Please add the information of the student you want to input \n"); do { printf(" Input student ID (12 digit )\n");
//do-while loop , Wrong input , There are hints ( Student number is 12 A number ) scanf("%s",&stu[count].num);
len=strlen(stu[count].num); }while(len!=12); printf(" Enter the name of the student ( letter )\n");
scanf("%s",stu[count].name); printf(" Enter the major code of the student :1 Internet of things project 2 Computer science and technology 3 software engineering 4 big data
\n"); // This method solves the problem of professional input scanf("%d",&stu[count].zy); printf(" Enter student class number :1,1841
2,1842 \n"); scanf("%d",&stu[count].bj); do { printf(" Input no more than in sequence 100 Students' scores in various subjects \n");
printf(" mathematics , English , Professional introduction course ,C language , Sports \n");
scanf("%d%d%d%d%d",&stu[count].math,&stu[count].yy,&stu[count].dl,&stu[count].cyy,&stu[count].ty);
}while(stu[count].math>100||stu[count].yy>100||stu[count].dl>100||stu[count].cyy>100||stu[count].ty>100);
// Judge whether the score exceeds 100 , If it exceeds, re-enter it
stu[count].s=(stu[count].math+stu[count].yy+stu[count].dl+stu[count].cyy+stu[count].ty);
// Total score first stu[count].pj=stu[count].s/5.0; // Get the average count++; // Enter the number of student achievement information } void
output(struct student stu[M]) //******* Output function ****** { int j; system("cls");// Clear screen statement
if (count==0) { printf(" At present, there is no student information record \n"); return; } for (j=0;j<count;j++) { for
(j=0;j<count;j++) { //for The number of cyclic control outputs printf(" Student number :%s ",stu[j].num); printf(" full name :%s
",stu[j].name); if (stu[j].zy==1) printf(" major : Internet of things project "); else if (stu[j].zy==2)
printf(" major : Computer science and technology "); else if(stu[j].zy==3) printf(" major : software engineering "); else
printf(" major : big data "); printf(" class :184%d ",stu[j].bj); printf(" mathematics :%d ",stu[j].math);
printf(" English :%d ",stu[j].yy); printf(" Introduction to professional courses :%d ",stu[j].dl); printf("C language :%d
",stu[j].cyy); printf(" Sports :%d ",stu[j].ty); printf(" Total score :%d ",stu[j].s);
printf(" average :%.1lf ",stu[j].pj); printf(" order :%d \n",j+1); } } } void
chakang(struct student stu[M]) //***** View functions *** { int j=0; char
xh[25];// Search student information through student number system("cls"); if(count==0) { printf(" There is no student information at present \n"); return;
} else { printf(" Please input the student number you want to view (12 Digit number )\n"); scanf("%s",&xh);
fflush(stdin);// Clear input buffer for(j=0;j<count;j++) {
if(strcmp(stu[j].num,xh)==0)// Determine whether the sizes are equal { printf(" Student number :%s ",stu[j].num);
printf(" full name :%s ",stu[j].name); if (stu[j].zy==1) printf(" major : Internet of things project "); else if
(stu[j].zy==2) printf(" major : Computer science and technology "); else if(stu[j].zy==3) printf(" major : software engineering
"); else printf(" major : big data : "); printf(" class :184%d ",stu[j].bj); printf(" mathematics :%d
",stu[j].math); printf(" English :%d ",stu[j].yy); printf(" Introduction to professional courses :%d ",stu[j].dl);
printf("C language :%d ",stu[j].cyy); printf(" Sports :%d ",stu[j].ty); printf(" Total score :%d
",stu[j].s); printf(" average :%.1lf ",stu[j].pj); // ******* When viewing individual student grades , You can see the total score ranking *****
int a,b,c=j; for (a=0;a<count;a++) //***** Bubble sort *** { for (b=a+1;b<count;b++) {
if (stu[b].s>stu[a].s) { t=stu[b]; stu[b]=stu[a]; stu[a]=t; } } } int d=1;
for(a=0;a<count;a++) { if(stu[c].s<stu[a].s) d++; else break; }
printf(" Total score ranking :%d\n",d); } } if(j==count)// Judge whether there is information about students' grades printf(" There is no student information you are looking at \n"); }
} void gai(struct student stu[M]) //*** Modify grade function *** { int j,course; char xh[25];
system("cls");// Clear screen statement if (count==0)// Judge whether there is information about students' grades { printf(" There is no student information at present \n"); return;
} else { printf(" The revised student number is :\n"); scanf("%s",&xh); fflush(stdin);// Clear input buffer for
(j=0;j<count;j++) if (strcmp(stu[j].num,xh)==0) // { printf(" Revise student grades \n");
printf(" Choose a course : 1, mathematics 2, English 3, Introduction to professional courses 4,C language 5, Sports \n"); scanf("%d",&course);
printf(" What's the score :\n"); switch(course) { // Modify the score of one of the selected students case
1:scanf("%d",&stu[j].math);break; case 2:scanf("%d",&stu[j].yy);break; case
3:scanf("%d",&stu[j].dl);break; case 4:scanf("%d",&stu[j].cyy);break; case
5:scanf("%d",&stu[j].ty);break; default:printf(" Please re-enter \n");break; } } } } void
del(struct student stu[M]) // Custom delete function { int choice; system("cls");// Clear screen statement if
(count==0) { printf(" There is no student information at present \n"); return; } else { printf(" Please select the way you want to delete :1, Student number
2, full name 3, cancel \n"); scanf("%d",&choice); switch(choice) { case 3:return;break; case
2:name_(stu);break; case 1:num_(stu);break;
default:printf(", Input error , Reenter \n");break; } } } void num_(struct student stu[M])
// Delete student information function by student number { int j,index=0,k=count; char xh[25]; system("cls");// Clear screen statement
printf(" The student ID to be deleted is :\n"); scanf("%s",xh); fflush(stdin);// Clear input buffer for
(j=0;j<count;j++) { if (strcmp(stu[j].num,xh)==0) { for (j=index;j<count;j++)
stu[j]=stu[j+1]; count--; if (count<k) printf(" Successfully deleted \n"); } index++;} if
(j==count) printf(" There is no information about the student you want to delete \n"); } void name_(struct student stu[M])
// Delete student information function by name { int flag=0,j,k=count; char xm[25]; system("cls");// Clear screen statement
printf(" The student ID to be deleted is :\n"); scanf("%s",xm); fflush(stdin);// Clear input buffer for
(j=0;j<count;j++) { if (strcmp(stu[j].num,xm)==0) { for (j=flag-1;j<count;j++)
stu[j]=stu[j+1]; count--; if (count<k) printf(" Successfully deleted \n"); } flag++;} if
(j==count) printf(" There is no information about the student you want to delete \n"); } void order(struct student stu[M])
// Sorting function { int j,choice,i; system("cls");// Clear screen statement
printf(" Please enter the way you want to sort ( All sorts are in descending order )!!!\n"); printf("1, mathematics 2, English 3, Introduction to Internet of things 4,C language 5, Sports
6, average 7, Student number 8, Professional serial number ranking \n"); scanf("%d",&choice); //******** Bubble sort is used in the following ***** switch
(choice) { case 1:for (i=0;i<count;i++) // ** Mathematics ranking ( High marks --> Low score )** { for
(j=i+1;j<count;j++) { if (stu[j].math>stu[i].math) { t=stu[j]; stu[j]=stu[i];
stu[i]=t; } } };break; case 2:for (i=0;i<count;i++) //** English ranking ( High marks --> Low score )** { for
(j=i+1;j<count;j++) { if (stu[j].yy>stu[i].yy) { t=stu[j]; stu[j]=stu[i];
stu[i]=t; } } } break; case 3:for (i=0;i<count;i++) // ** Ranking of introduction to professional courses ( High marks --> Low score )** {
for (j=i+1;j<count;j++) { if (stu[j].dl>stu[i].dl) { t=stu[j]; stu[j]=stu[i];
stu[i]=t; } } } break; case 4:for (i=0;i<count;i++) // *** C Language ranking ( High marks --> Low score )** {
for (j=i+1;j<count;j++) { if (stu[j].cyy>stu[i].cyy) { t=stu[j]; stu[j]=stu[i];
stu[i]=t; } } } break; case 5:for (i=0;i<count;i++) // ** Sports ranking ( High marks --> Low score )** { for
(j=i+1;j<count;j++) { if (stu[j].ty>stu[i].ty) { t=stu[j]; stu[j]=stu[i];
stu[i]=t; } } } break; case 6:for (i=0;i<count;i++) // average ( Total score ) ranking ( High marks --> Low score ) *** {
for (j=i+1;j<count;j++) { if (stu[j].pj>stu[i].pj) { t=stu[j]; stu[j]=stu[i];
stu[i]=t; } } } break; case 7:for (i=0;i<count;i++) // ** Student number ranking ( Small to large ) ** { for
(j=i+1;j<count;j++) { if (strcmp(stu[j].num,stu[i].num)<0) { t=stu[j];
stu[j]=stu[i]; stu[i]=t; } } } break; case 8:for (i=0;i<count;i++) // **
Professional serial number ranking ( Small to large ) { for (j=i+1;j<count;j++) { if (stu[j].zy<stu[i].zy) { t=stu[j];
stu[j]=stu[i]; stu[i]=t; } } } break; default:printf(" Please re-enter \n");break; } }

Technology
©2019-2020 Toolsou All rights reserved,
The 11th Blue Bridge Cup python The real topic of the University Group National Games JavaSwing To achieve a simple Lianliankan games 【Spring Source code analysis 】42-@Conditional Detailed explanation element-ui Step on pit record 2019PHP Interview questions ( Continuously updated )PHPJava Misunderstanding —— Method overloading is a manifestation of polymorphism ? First issue 500 100 million , Set up a new Department , What is Tencent going to do ? Google chrome The browser can't open the web page , But what if other browsers can open it ? Regression of dependent variable order categories (R language )【Golang Basic series 10 】Go language On conditional sentences if