Student statistics

xiaoxiao2021-03-05  22

Enter a class (full class 30 people) student's student number, name, M door course, respectively, statistics: 1. Counting the total score of each student, according to the total score from the total to small discharge. 2. Print the list of students on the average of the scores (need to be implemented with a list structure)

============================================================================================================================================================================================================= ================================

#include #include #include #define m 3 / * Set the account to 3. You can modify * / #define P 30 / * can be changed when testing * / typef strufft s {int ID; float all, ave, score [m]; char name [10]; / * Name 10 should be enough. * / Struct S * next;} student; student * createstu () / * Join point * / {INT i; student * s = (student *) malloc (SIZEOF (STUDENT)); Printf ("please input the ID / n"); scanf ("% d", & s-> id) PRINTF ("please input the name / n"); fflush (stdin); Gets (S-> Name); Printf ("please input the score / n"); i = 0; S-> ALL = 0; while (i score [i]); S-> ALL = S-> score [i ]; if (i == m) S-> AVE = S-> All / i;} S-> Next = 0; Return S;} student * insertlink (student * & head, student * node) {student * p = head, * q = p; if (! HEAD) / * Insert head * / {Head = node; return head;} ​​if (head-> all all) / * inserted in front * / {node-> next = head; head = nod e; return head;} ​​while (p && (p-> all> = node-> all)) {q = p; p = p-> next;} if (! p) p = node; / * Insert tail * / ELSE / * insertion * / {q-> next = node; node-> next = p; q = node;} return head;} ​​void print (student * head) {student * p = head; if (! p) Return; Printf ("/ nshow these students with other information / n"); while (p) {printf ("ID:% D Name:% s all:% f average:% f / n", p-> id, P-> Name, P-> All, P-> AVE);

转载请注明原文地址:https://www.9cbs.com/read-35623.html

New Post(0)