#include
#include
# define MaxSize 30
Struct student {
int num;/* */student id
Char name [20]={'/0};/* name */
Int Chinese, English, math,/* three classes grades */
Float business;/* personal average */
};
/* */input function
Void new_student (struct student students [])
{
Int I, n, Count;
If (Count==MaxSize) {
Printf (" full! \n");
return;
}
Printf (" please enter the serial number of the students: ");
The scanf (" % d ", & amp; N);
for(i=0; i
Printf (" please enter the student's student id: ");
The scanf (" % d ", & amp; Students [I] num);
Printf (" please enter the student's name: ");
The scanf (" % s ", & amp; Students [I] name);
Printf (" please enter the student's language result: ");
The scanf (" % d ", & amp; Students [I]. Chinese);
Printf (" please input the student's mathematics result: ");
The scanf (" % d ", & amp; Students [I]. Math);
Printf (" please enter the student's English: ");
The scanf (" % d ", & amp; Students [I]. English);
Count++;
}
}
/* */output function
Void output_student (struct student students [])
{
Int I, Count;
If (Count==0) {
printf("\n");
return;
}
Printf (" num math \ \ t t Chinese name \ \ t t t business English \ \ n ");
for(i=0; i
Printf (" % s \ t ", students [I] name);
Printf (" % d \ t ", students [I]. Chinese);
Printf (" % d \ t ", students [I]. Math);
Printf (" % d \ t ", students [I] English);
Printf (" % f \ t \ n ", students [I] business);
}
}
/* calculate average score function */
Void business (struct student s [])
{
int i;
Int Count;
for(i=0; i
}
/* average sort function */
Void sort (struct student s [])
{
Struct student temp.
Int I, index, j;
Int Count;
for(i=0; i
The index=I;
For (j + 1; J
The index=j;
Temp=s [index];
S [index] [I]=s;
S [I]=temp;
}
}
/* * modify performance function/
Void the modify (struct student * p)
{
Int num, course, score, I, the Count;
Printf (" please enter the result to the modified student's name: ");
The scanf (" % d ", & amp; Num);
Printf (" select courses: 1. Chinese 2. Math and English: ");
The scanf (" % d ", & amp; Of course);
Printf (" input new achievement: ");
The scanf (" % d ", & amp; Score);
for(i=0; i
break;
If (i
{
Case1: p - & gt; Chinese=score; break;
Case2: p - & gt; Math=score; break;
Case3: p - & gt; English=score; break;
}
}
/* */query student information function
Void search_student (struct student students [], int num)
{
Int I, flag=0, Count;
If (Count==0) {
printf("\n");
return;
}
for(i=0; i
Flag=1;
break;
}
If (flag) {
Printf (" num: % d ", students [I] num);
Name: printf (" % s ", students [I] name);
Printf (" Chinese: % d ", students [I]. Chinese);
Math: printf (" % d ", students [I]. Math);
Printf (" % d ". English, students [I] English);
Printf (" business: % 2 f \ n ", students [I] business);
}
The else
Printf (" can't find!" );
}
Int main (void)
{
Struct student students [MaxSize];/* define array */student information
New_student (students);/* */input student information structure array
Output_student (students);/* */display input student information structure array
Business (students);/* calculate each student's grade point average */
Sort (students);/* sort by the student's grade point average */
Output_student (students);/* shows the structure of the sorted array */
The modify (students);/* modify specified input student information */
Output_student (students);/* shows the structure of modified array */
return 0;
}
CodePudding user response:
# include & lt; stdio.h>
#include
# define MaxSize 30
Struct student {
int num;/* */student id
//char name [20]={'/0};/* name */
Char name [20].
Int Chinese, English, math,/* three classes grades */
Float business;/* personal average */
};
Int Count;
/* */input function
Void new_student (struct student students [])
{
Int I, n;//Count;//defined as global variables.
If (Count==MaxSize) {
Printf (" full! \n");
return;
}
Printf (" please input the number of the students: ");
The scanf (" % d ", & amp; N);
for(i=0; i{
Printf (" please enter the student's student id: ");
The scanf (" % d ", & amp; Students [I] num);
Printf (" please enter the student's name: ");
//the scanf (" % s ", & amp; Students [I] name);
The scanf (" % s ", students [I] name);
Printf (" please enter the student's language result: ");
The scanf (" % d ", & amp; Students [I]. Chinese);
Printf (" please input the student's mathematics result: ");
The scanf (" % d ", & amp; Students [I]. Math);
Printf (" please enter the student's English: ");
The scanf (" % d ", & amp; Students [I]. English);
Count++;
}
}
/* */output function
Void output_student (struct student students [])
{
int i;//Count;
If (Count==0) {
printf("\n");
return;
}
Printf (" num math \ \ t t Chinese name \ \ t t t business English \ \ n ");
for(i=0; iPrintf (" % d \ t ", students [I] num);
Printf (" % s \ t ", students [I] name);
Printf (" % d \ t ", students [I]. Chinese);
Printf (" % d \ t ", students [I]. Math);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull