Each student performance information includes: student id, Chinese, maths, English, total score, the weighted average; A dynamic method to create an array used to store a number of student achievement information; Enter the student's student id, Chinese, maths, English, Calculate the score of students and weighted average (50% Chinese (30%), math, English 20%);
Output student achievement information,
New student performance information can be appended at the end of the array; Can according to the student number, delete the student performance information, can according to the student id or total score, ascending sort student achievement information,
#include
#include
Typedef struct
Student_infor
{int studentID.
Float Chinese;
Float math;
Float English;
Float sum;
Float P_avarage;
Struct student_infor * next;
} student;
Student * input (int n)
{int I; Student * p, * stu.
For (I=0, stu=NULL; IstudentID, & amp; P - & gt; Chinese, & amp; P - & gt; Math, & amp; P - & gt; English);
P - & gt; Sum=(p - & gt; Chinese) (p - & gt; Math) (p - & gt; English);
P - & gt; P_avarage=(p - & gt; Chinese) * 0.3 (p - & gt; Math) * 0.5 (p - & gt; English) * 0.2;
P - & gt; Next=stu;
Stu=p;
}
Return stu.
}
Void the output (student * p)
{printf (" output student information: ");
Printf (" student student id: % d ", p - & gt; StudentID);
Printf (" language result: % 1 f ", p - & gt; Chinese);
Printf (" math: % 1 f ", p - & gt; Math);
English: printf (" % 1 f ", p - & gt; English);
Printf (" total score: % 1 f ", p - & gt; The sum);
Printf (" weighted average: % 1 f ", p - & gt; P_avarage);
}
Void visit (student * stu, void * fun () ())
{student * p;
For (p=stu. p!=NULL; P=p - & gt; Next)
{(* fun) (p);
}
} void delect (student * p, int ID)
{
Printf (" please enter need to delete the student student id: ");
The scanf (" % d ", & amp; ID);
Student * t=NULL, * s=NULL;
S=p;
T=p - & gt; Next;
While (t)
{
If ((t - & gt; StudentID)==ID)
{s - & gt; Next=t - & gt; Next;
}
The else {t=t - & gt; Next; S=s - & gt; Next;
}
}
} int main ()
{int n, m, ID;
Student * p, * stu.
Printf (" please enter the need to input the number of students: ");
The scanf (" % d ", & amp; N);
Stu=input (n);
Delect (p, ID);
Visit (stu, the output);
return 0;
}
CodePudding user response:
You put the wrong post ahCodePudding user response:
Made using a mobile phone, have been wrongCodePudding user response:
You can screenshots, no information about how to judge?