C language Structure edition student achievement management system

  • 2020-07-21 09:28:37
  • OfStack

The example of this paper shares the specific code of C language to achieve student achievement management system for your reference. The specific content is as follows

Structural version of the student achievement management system

The main functions are

Press 1 to enter student information
Press 2 to output student information
Press 3 for student information
Press 4 to modify student information
Press 5 to delete student information
Press 6 to insert student information
Sort the total score information by 7

Student information mainly includes name, class, student number, C language score, advanced mathematics score, college English score, the output format of console interface is a little ugly.


#include<stdio.h>
#include<string.h>
struct student
{
 char name[20];// The name 
 char sex[10];// gender 
 int number;// Student id 
 char ban[20];// The class 
 int c;//C Language performance 
 int gaoshu;// High number of scores 
 int yingyu;// College English Score 
 int sum;// Total grade 

}stu[60];
int n;// The number of students 
void menu()// The menu 
{
 printf("\n");
 printf("***********************************\n");
 printf("***  Student achievement management system  ***\n");
 printf("***  According to the 1  Enter student information  ***\n");
 printf("***  According to the 2  Output student information  ***\n");
 printf("***  According to the 3  Query student information  ***\n");
 printf("***  According to the 4  Modify student information  ***\n");
 printf("***  According to the 5  Delete student information  ***\n");
 printf("***  According to the 6  Insert student information  ***\n");
 printf("***  According to the 7  Ranking score information  ***\n");
 printf("***   According to the 0  Log out  ***\n");
 printf("***********************************\n");
}
void input()// Student information input 
{
 int i,j=1;
 printf("\n   Please enter the total number of students :");
 scanf("%d",&n);
 for(i=1;i<=n;i++)
 {
 printf("  Enter the first %d Information about students \n",j++);
 printf(" Enter the name \n");
 scanf("%s",stu[i].name);
 getchar();
 printf(" Enter the gender \n");
 scanf("%s",stu[i].sex);
 printf(" Enter the student id \n");
 scanf("%d",&stu[i].number);
 printf(" Enter the class \n");
 scanf("%s",stu[i].ban);
 printf(" The input c Language performance \n");
 scanf("%d",&stu[i].c);
 printf(" Enter high scores \n");
 scanf("%d",&stu[i].gaoshu);
 printf(" Enter your college English score \n");
 scanf("%d",&stu[i].yingyu);
 stu[i].sum=stu[i].c+stu[i].gaoshu+stu[i].yingyu;
 printf(" The student's total score :%d\n",stu[i].sum);
 

 

 }
}
void output()// Student information output 
{
 int i;
 printf("---------- Student information is ----------\n");
 if(n==0)printf(" ++++++ There's no information here ++++++\n");
 else for(i=1;i<=n;i++)
 {
 printf(" Name: %2s",stu[i].name);
 printf(" Gender: %2s",stu[i].sex);
 printf(" Student number: %2d",stu[i].number);
 printf(" Class: %2s",stu[i].ban);
 printf("c Language Score: %2d\n",stu[i].c);
 printf(" Advanced Grades: %2d\n",stu[i].gaoshu);
 printf(" English Score: %2d\n",stu[i].yingyu);
 stu[i].sum=stu[i].c+stu[i].gaoshu+stu[i].yingyu;
 printf(" The student's total score :%d\n",stu[i].sum);
 }

}
void search()// The query 
{
 int num,i,t;
 char a[20],k;
 if(n!=0)
 {
 printf(" Select search criteria (1: Student id  2: The name )\n");
 scanf("%d",&t);
 if(t==1)
 {
 printf(" Enter the student number you are looking for \n");
  scanf("%d",&num);
 for(i=1;i<=n;i++)
 {
 if(stu[i].number==num)
 {
 printf(" Name: %s",stu[i].name);
  printf(" Gender: %s",stu[i].sex);
  printf(" Student number: %d",stu[i].number);
  printf(" Class: %s",stu[i].ban);
  printf("c Language Score: %d\n",stu[i].c);
 printf(" Advanced Grades: %d\n",stu[i].gaoshu);
 printf(" English Score: %d\n",stu[i].yingyu);
 stu[i].sum=stu[i].c+stu[i].gaoshu+stu[i].yingyu;
  printf(" The student's total score :%d\n",stu[i].sum);
 break;
 }
 } if(i>n) printf(" The information you are looking for does not exist or the student number is entered incorrectly \n");
 }
 if(t==2)
 {
 printf(" Enter the name of the student you are looking for \n");
 scanf("%s",a);
 for(i=1;i<=n;i++)
 {
 k=strcmp(stu[i].name,a);
 if(k==0)
 {
 printf(" Name: %s",stu[i].name);
  printf(" Gender: %s",stu[i].sex);
  printf(" Student number: %d",stu[i].number);
  printf(" Class: %s",stu[i].ban);
  printf("c Language Score: %d\n",stu[i].c);
 printf(" Advanced Grades: %d\n",stu[i].gaoshu);
 printf(" English Score: %d\n",stu[i].yingyu);
 stu[i].sum=stu[i].c+stu[i].gaoshu+stu[i].yingyu;
  printf(" The student's total score :%d\n",stu[i].sum);
 break;

 }
 }if(i>n) printf(" The information you are looking for does not exist or the student number is entered incorrectly \n");
 }

 }
 else printf(" Sorry, there is no student information here \n");

 

}
void change()// Modify the 
{
 int num,i;
 printf(" Enter the student number you want to modify \n");
 scanf("%d",&num);
 if(n==0) printf(" ++++++ There's no information here ++++++\n");
 else
 {
 for(i=1;i<=n;i++)
 {
 if(stu[i].number==num)
 {
 printf(" The student information you want to modify is \n");
 printf(" Name: %s",stu[i].name);
  printf(" Gender: %s",stu[i].sex);
  printf(" Student number: %d",stu[i].number);
  printf(" Class: %s",stu[i].ban);
  printf("c Language Score: %d\n",stu[i].c);
 printf(" Advanced Grades: %d\n",stu[i].gaoshu);
 printf(" English Score: %d\n",stu[i].yingyu);
 stu[i].sum=stu[i].c+stu[i].gaoshu+stu[i].yingyu;
  printf(" The student's total score :%d\n",stu[i].sum);
 printf("\n");
 break;

 }
 
 }

 if(i>n) printf(" The information you are looking for does not exist or the student number is entered incorrectly \n");
 else
 {
  printf(" Enter the name \n");
 scanf("%s",stu[i].name);
 getchar();
 printf(" Enter the gender \n");
 scanf("%s",stu[i].sex);
 printf(" Enter the student id \n");
 scanf("%d",&stu[i].number);
 printf(" Enter the class \n");
 scanf("%s",stu[i].ban);
 printf(" The input c Language performance \n");
 scanf("%d",&stu[i].c);
 printf(" Enter high scores \n");
 scanf("%d",&stu[i].gaoshu);
 printf(" Enter your college English score \n");
 scanf("%d",&stu[i].yingyu);
 }
 }
}
void del()// delete 
{
 int i,j,e,num;
 if(n!=0)
 {
 printf(" **** This is information for all students ****\n");
 for(i=1;i<=n;i++)
 {
 printf("--------------------------*\n");
 printf(" Name: %s\n",stu[i].name);
 printf("    *\n");
 printf(" Gender: %s\n",stu[i].sex);
 printf("    *\n");
 printf(" Student number: %d\n",stu[i].number);
 printf("    *\n");
 printf(" Class: %s\n",stu[i].ban);
 printf("    *\n");
 printf("c Language Score: %d\n",stu[i].c);
 printf(" Advanced Grades: %d\n",stu[i].gaoshu);
 printf(" English Score: %d\n",stu[i].yingyu);
 stu[i].sum=stu[i].c+stu[i].gaoshu+stu[i].yingyu;
 printf(" The student's total score :%d\n",stu[i].sum);
 printf("--------------------------*\n");
 }
 printf(" Please enter the student number you want to delete :");
 scanf("%d",&num);
 for(i=1;i<=n;i++)
 if(stu[i].number==num)
 {
 j=i;
 for(e=i-1;e<n;e++,j++)
 {
 strcpy(stu[j].name,stu[j+1].name);
 strcpy(stu[j].sex,stu[j+1].sex);
 stu[j].number=stu[j+1].number;
 strcpy(stu[j].ban,stu[j+1].ban);
 stu[j].c=stu[j+1].c;
 stu[j].gaoshu=stu[j+1].gaoshu;
 stu[j].yingyu=stu[j+1].yingyu;
 n--;
 }
 }printf("********** The student information has been deleted **********\n");

 }
 else printf(" Sorry, there is no student information here \n");

 
 
 
}
void add()// insert 
{
 int i,j,t;
 if(n!=0)
 {
 printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
 printf("^  note :  Please do not insert the following information if it is repeated  ^\n");
 printf("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n");
 printf("\n");
 for(i=1;i<=n;i++)
 {
 
  printf(" Name: %s",stu[i].name);
  printf(" Gender: %s",stu[i].sex);
  printf(" Student number: %d",stu[i].number);
  printf(" Class: %s",stu[i].ban);
  printf("c Language Score: %d\n",stu[i].c);
 printf(" Advanced Grades: %d\n",stu[i].gaoshu);
 printf(" English Score: %d\n",stu[i].yingyu);
 stu[i].sum=stu[i].c+stu[i].gaoshu+stu[i].yingyu;
  printf(" The student's total score :%d\n",stu[i].sum);
 printf("\n");
 }
 printf(" Whether to continue inserting ( Is this: y  No: n)\n");
 printf("%c Your choice is :",t=getchar());
 t=getchar();
 if(t=='y')
 {
 j=n;
 printf("********** Please insert student information **********\n");
  printf(" Enter the name \n");
  scanf("%s",stu[j+1].name);
 getchar();
  printf(" Enter the gender \n");
  scanf("%s",stu[j+1].sex);
  printf(" Enter the student id \n");
  scanf("%d",&stu[j+1].number);
  printf(" Enter the class \n");
  scanf("%s",stu[j+1].ban);
  printf(" The input c Language performance \n");
  scanf("%d",&stu[j+1].c);
 printf(" Enter high scores \n");
  scanf("%d",&stu[j+1].gaoshu);
 printf(" Input English score \n");
  scanf("%d",&stu[j+1].yingyu);
 strcpy(stu[j+2].name,stu[j+1].name);
 strcpy(stu[j+2].sex,stu[j+1].sex);
 stu[j+2].number=stu[j+1].number;
 strcpy(stu[j+2].ban,stu[j+1].ban);
 stu[j+2].c=stu[j+1].c;
 stu[j+2].gaoshu=stu[j+1].gaoshu;
 stu[j+2].yingyu=stu[j+1].yingyu;
 printf("   The student information has been inserted \n");
 n++;
 }else printf("\n ( � � � ) Insert program finished, please select again ");printf("\n");
 
 }
 else{i=1;printf(" Please enter information about the student you want to insert \n");
  printf(" Enter the name \n");
 scanf("%s",stu[i].name);
 getchar();
 printf(" Enter the gender \n");
 scanf("%s",stu[i].sex);
 printf(" Enter the student id \n");
 scanf("%d",&stu[i].number);
 printf(" Enter the class \n");
 scanf("%s",stu[i].ban);
 printf(" The input c Language performance \n");
 scanf("%d",&stu[i].c);
 printf(" Enter high scores \n");
 scanf("%d",&stu[i].gaoshu);
 printf(" Input English score \n");
 scanf("%d",&stu[i].yingyu);
 n++;
 
 }
 
}
void paixu()
{
 int i,j,t;
if(n!=0)
{
 printf(" The ranking is based on the overall score from highest to lowest \n");
 for(i=1;i<=n;i++)
  for(j=1;j<n;j++)
 { 
   if(stu[j].sum<stu[j+1].sum)
   {
   t=stu[j].sum;
   stu[j].sum=stu[j+1].sum;
   stu[j+1].sum=t;
   }
 }
 for(i=1;i<=n;i++)
 {
 printf(" Name: %s\n",stu[i].name);
 printf(" Gender: %s\n",stu[i].sex);
 printf(" Student number: %d\n",stu[i].number);
 printf(" Class: %s\n",stu[i].ban);
 printf("c Language Score: %d\n",stu[i].c);
 printf(" Advanced Grades: %d\n",stu[i].gaoshu); 
 printf(" Overall: %d\n",stu[i].sum);
 }
 
}
else printf(" ++++++ There's no information here ++++++\n");
}
void main()
{
 int a,b=1;
 while(b)
 {
 menu();
 printf(" What you have chosen is : ");
 scanf("%d",&a);
 printf("\n");
 switch(a)
 {
 case 1:input();break;// The input 
 case 2:output();break;// The output 
 case 3:search();break;// To find the 
 case 4:change();break;// Modify the 
 case 5:del();break;// delete 
 case 6:add();break;// insert 
 case 7:paixu();break;// The sorting 
 case 0:b=0;break;// exit 
 }
 }
 printf("  Student management system has been withdrawn ( ^_^ )\n");
}

For more information, please pay attention to the topic management System Development.


Related articles: