Home > Back-end >  Student achievement management system of sorting to solve
Student achievement management system of sorting to solve

Time:09-21

# include "stdio.h"
# include "stdlib. H"
# include "string. H"
//# define Length sizeof (struct student) to open up space
Int n=0;
Struct student
{
char name[20];//name
Char sex [20].//gender
Char Class [20].//class
Char major [20].//
int age;//age
Int cgrade;//C grade
Int mgrade;//math
Int egrade;//English
Int pgrade;//PE
Int lgrade;//the language achievement
Int avg.//average
Struct student * next;
} * head, * p, * p1, * (p2);//the head said the first p is the location of different data
Void the add ()//add
{p1=(struct student *) malloc (Length);//set up storage space
If (n==0)//judgment list beginning
The head=p1;//n=0 represents the input is the end of the first data//p2 points to address is p1
The else p2 - & gt; Next=p;//n!=0 are they connect
system("cls");
Printf (" please input the basic information: \ n name: ");
The scanf (" % s ", & amp; P1 - & gt; Name);
Printf (" gender: ");
The scanf (" % s ", & amp; P1 - & gt; Sex);
Printf (" age: ");
The scanf (" % d ", & amp; P1 - & gt; The age);
Printf (" class: ");
The scanf (" % s ", & amp; P1 - & gt; The Class);
Printf (" professional: ");
The scanf (" % s ", & amp; P1 - & gt; Major);
Printf (" C: ");
The scanf (" % d ", & amp; P1 - & gt; Cgrade);
Printf (" math: ");
The scanf (" % d ", & amp; P1 - & gt; Mgrade);
Printf (" English: ");
The scanf (" % d ", & amp; P1 - & gt; Egrade);
Printf (" sports achievement: ");
The scanf (" % d ", & amp; P1 - & gt; Pgrade);
Printf (" language result: ");
The scanf (" % d ", & amp; P1 - & gt; Lgrade);
p2=p1;/p1/p2 to address
The p2 - & gt; Next=NULL;//terminated list
N +=1;//n judgment is the first data
system("pause");//for order
system("cls");
}
Void the print ()
{
If (n!=0)
{
P=the head;//p points to start first
system("cls");
Printf (" name gender \ t \ \ t t class professional \ t \ \ t age tC language achievement scored an average English sports scores in math language result \ n ");
Do
{p1 - & gt; Avg=(p1 - & gt; Cgrade + p1 - & gt; Mgrade + p1 - & gt; Egrade + p1 - & gt; Pgrade + p1 - & gt; Lgrade)/5;
Printf (" % % - 8 - s - 16 s % % - 8 - s - 8 - d - 16 s % % - 8-8-8 d % d % d % - 5.2-8 8 d % d % d \ n ", p - & gt; The name, p - & gt; Sex, p - & gt; Class, p - & gt; Age, p - & gt; Major, p - & gt; Cgrade, p - & gt; Mgrade, p - & gt; Egrade, p - & gt; Pgrade, p - & gt; Lgrade, p - & gt; Avg);
P=p - & gt; next;//p to print over the p point next to determine any content next area
} while (p!=NULL);//as long as the memory area of p points to data to print content
}
The else
Printf (" * * * * * * you do not have to add data! \n");
system("pause");
system("cls");
}
Void the find ()//find
{
char a[20];
Printf (" please enter a name to find: ");
The scanf (" % s ", & amp; A);
P=the head;
Do
{
If (STRCMP (a, p - & gt; Name)==0)
{p1 - & gt; Avg=(p1 - & gt; Cgrade + p1 - & gt; Mgrade + p1 - & gt; Egrade + p1 - & gt; Pgrade + p1 - & gt; Lgrade)/5;
Printf (" \ n information has been found: \ n name gender \ t \ \ t t class professional \ t \ \ t age tC language achievement scored an average English sports scores in math language result \ n ");
Printf (" % % - 8 - s - 16 s % % - 8 - s - 8 - d - 16 s % % - 8-8-8 d % d % d % - 5.2-8 8 d % d % d \ n \ n ", p - & gt; The name, p - & gt; Sex, p - & gt; Class, p - & gt; Age, p - & gt; Major, p - & gt; Cgrade, p - & gt; Mgrade, p - & gt; Egrade, p - & gt; Pgrade, p - & gt; Lgrade, p - & gt; Avg);

} p=p - & gt; next;//pointer to the next node
} while (p!=NULL);
Printf (" * * * * * * you do not have to add data! \n");
system("pause");
system("cls");
}
Void the Delete ()
{
If (n!=0)
{
F, struct student * * l;//pointer to define new f used to point to want to delete the data used to release the memory!
char a[20];
Printf (" please enter a name to delete: ");
The scanf (" % s ", & amp; A);
P=the head;
If (STRCMP (head - & gt; The name, a)==0)
{f=head; The head=head - & gt; next; Free (f); }
The else
{
Do
{
If (STRCMP (p - & gt; The name, a)==0)
{f=p; L - & gt; Next=p - & gt; next; Free (f); break; }
L=p;//does not meet the if said this is not the man you want to delete a node, temporarily to p l p then point to the next node, if this is to delete the node l point to the next node address
P=p - & gt; next;
} while (p!=NULL);
}
}
The else
Printf (" * * * * * * you do not have to add data! \n");
Printf (" data has been deleted \ n ");
system("pause");//for order
system("cls");
}
Void amend ()
{
If (n!=0)
{
int c;
char a[20];
Printf (" please input to modify the name: ");
The scanf (" % s ", & amp; A);
P=the head;
Do
{
If (STRCMP (a, p - & gt; Name)==0)
{p1 - & gt; Avg=(p1 - & gt; Cgrade + p1 - & gt; Mgrade + p1 - & gt; Egrade + p1 - & gt; Pgrade + p1 - & gt; Lgrade)/5;
Printf (" \ n be modified information is as follows: \ n name gender \ t \ \ t t class professional \ t \ \ t age tC language achievement scored an average English sports scores in math language result \ n ");
Printf (" % % - 8 - s - 16 s % % - 8 - s - 8 - d - 16 s % % - 8-8-8 d % d % d % - 5.2-8 8 d % d % d \ n ", p - & gt; The name, p - & gt; Sex, p - & gt; Class, p - & gt; Age, p - & gt; Major, p - & gt; Cgrade, p - & gt; Mgrade, p - & gt; Egrade, p - & gt; Pgrade, p - & gt; Lgrade, p - & gt; Avg);
break;
}
P=p - & gt; next;////pointer to the next node
} while (p!=NULL);
Printf (" \ \ n \ n1. Modify the name n2 change gender \ n3 modified class \ n4 interchange modify age \ n5. The modified professional \ n6 modified C grades \ n7 modify math \ n8 modify English \ n9 modified PE \ n10 modify language result \ n11 exit modify \ n \ n ");
The scanf (" % d ", & amp; C);
The switch (c)
{
Case 1:
Printf (" name is amended as: ");
The scanf (" % s ", & amp; P - & gt; Name); break;
Case 2:
Printf (" gender is amended as: ");
The scanf (" % s ", & amp; P - & gt; Sex); break;
Case 3:
Printf (" class is amended as: ");
The scanf (" % s ", & amp; P - & gt; The Class); break;
Case 4:
Printf (" age is amended as: ");
The scanf (" % d ", & amp; P - & gt; The age); break;
Case 5:
Printf (" professional is amended as: ");
The scanf (" % s ", & amp; P - & gt; Major); break;
Case 6:
Printf (" C language result is amended as: ");
The scanf (" % d ", & amp; P - & gt; Cgrade); break;
Case 7:
Printf (" math grades is amended as: ");
The scanf (" % d ", & amp; P - & gt; Mgrade); break;
Case 8:
Printf (" English is amended as: ");
The scanf (" % d ", & amp; P - & gt; Egrade); break;
Case 9:
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related