The suspected violation of this floor has been folded by the system. Hide this floor to view this floor
Short answer questions]
Experiment task: Statistics of student achievement
Input the grades of a certain course of students in a class (no more than 30 students in the whole class) from the keyboard. When the input grade is negative, the input ends, and the following functions are realized respectively:
(1) Count the number of unqualified students and print the list of unqualified students;
(2) Count the number of students whose grades are above and above the average grade of the whole class, and print the list of these students;
(3) Count the number of students in each fraction and their percentage. (0-59 60-74 75-84 85-100)
Experimental requirements:
1. Store the functions of the above three functions in the chengji.c file, and store the function declarations in the chengji.h header file;
3. It is required to have a good input and output human-computer interaction design, and the program should be as fault-tolerant as possible.
Related tip: How to define an array as a function parameter:
A one-dimensional array inta[30]; is defined in the calling function as an actual parameter;
Function definition: int func(int a[]) indicates that the formal parameter is a one-dimensional array.
Note: If the data value in the array as a formal parameter is changed in the called function, the array argument value of the calling function is changed, because the array name is a memory address.
#include
intmain()
{
int s[30];
int i, m = 0;
for (i = 0; i < 30;i++) {
scanf_s("%d", &s[i]);
m++;
if (s[i] < 0)
break;
}
int count1 = 0;
printf("Failed student list: ");
for (i = 0; i < m -1; i++) {
if (s[i] < 60) {
printf("%d ", i);
count1++;
}
}
printf("\n The number of people who failed is: %d\n", count1);
double average;
int count2 = 0 , sum =0;
for (i = 0; i < m -1; i++) {
sum+= s[i];
}
average= sum * 1.0 / m;
printf(" 成绩在全班平均分及平均分之上的学生名单:");
for (i = 0; i < m -1; i++) {
if (s[i] >=average)
printf("%d ", i);
count2++;
}
printf("\n 成绩在全班平均分及平均分之上的学生人数为:%d\n", count2);
int A=0, B=0, C=0, D=0;
double a, b, c, d;
for (i = 0; i < m -1; i++) {
if (s[i] >= 85&& s[i] <= 100)
A++;
if (s[i] >= 75&& s[i] <= 84)
B++;
if (s[i] >= 60&& s[i] <= 74)
C++;
if (s[i] <= 59)
D++;
}
a= A * 1.0 / m;
b= B * 1.0 / m;
c= C * 1.0 / m;
d= D * 1.0 / m;
printf(" 85-100分数段的学生人数及所占的百分比为:%lf\n 75-84分数段的学生人数及所占的百分比为:%lf\n 60-74分数段的学生人数及所占的百分比为:%lf\n 0-60分数段的学生人数及所占的百分比为:%lf\n", a, b, c, d);
return 0;
}