#include <stdio.h> #include <stdlib.h> const int N=5; // definition of the structure type struct student, and to define its alias STU typedef struct Student { Long NO; char name [ 20 is ]; int Score; }STU; // 函数声明 void input(STU s[], int n); int findMinlist(STU s[], STU t[], int n); void output(STU s[], int n); int main () { Stu [N], minlist [N]; int count; the printf ( " enter student information% d \ n- " , N); input(stu, N); printf ( " \ the n-lowest score statistics and the number of student information ... \ the n- " ); count = findMinlist(stu, minlist, N); printf ( " \ a total of% d the n-th lowest score, the following information: \ the n- " , COUNT); output(minlist, count); system("pause"); return 0; } // input n students information stored in an array of structures in s void INPUT (the STU s [], int n) { int I; for (I = 0 ; I <n; I ++ ) scanf("%ld %s %d", &s[i].no, s[i].name, &s[i].score); } // output structure information of elements s n in void Output (the STU s [], int n) { int I; for (I = 0 ; I <n; I ++ ) printf("%ld %s %d\n", s[i].no, s[i].name, s[i].score); } // In the structure of the array s, find the lowest grade recording, which is stored in an array of structures in s // parameter n s is the array of structures in the number of elements // enrollment function returns the lowest points int findMinlist (the STU S [], the STU T [], int n-) { // complement function implemented // ××× int I, K = 0 , min; min= s[0].score; for(i=0;i<n;i++) { if(min> s[i].score) min= s[i].score; } for(i=0;i<n;i++) { if(min==s[i].score) t[k++]= s[i]; } return k; }
#include <stdio.h> #include <stdlib.h> #include <string.h> const int N = 10; // definition of the structure type struct student, and to define an alias for the STU typedef struct Student { Long int ID; char name [ 20 is ]; a float Objective; / * objective test score * / a float subjective; / * operation questions score * / a float SUM; char Level [ 10 ]; }STU; // 函数声明 void input(STU s[], int n); void output(STU s[], int n); void process(STU s[], int n); int main() { STU stu[N]; printf("录入%d个考生信息: 准考证号,姓名,客观题得分(<=40),操作题得分(<=60)\n", N); input(stu, N); printf("\n对考生信息进行处理: 计算总分,确定等级\n"); process(stu, N); printf("\n打印考生完整信息: 准考证号,姓名,客观题得分,操作题得分,总分,等级\n"); output(stu, N); system("pause"); return 0; } // 录入考生信息:准考证号,姓名,客观题得分,操作题得分 void input(STU s[], int n) { // 补足代码 // ××× int i; for(i=0;i<n;i++) {scanf("%ld %s %f %f",&s[i].id,s[i].name,&s[i].objective,&s[i].subjective);} } //输出考生完整信息: 准考证号,姓名,客观题得分,操作题得分,总分,等级 void output(STU s[], int n) { // 补足代码 // ××× int i; for(i=0;i<n;i++) {printf("%-ld %-s %.2f %.2f %.2f %-s\n",s[i].id,s[i].name,s[i].objective,s[i].subjective,s[i].sum,s[i].level);} } // 对考生信息进行处理:计算总分,排序,确定等级 void process(STU s[], int n) { // 补足代码 // ××× int i,j; STU temp; for(i=0;i<n;i++) {s[i].sum=s[i].objective+s[i].subjective;} for(i=0;i<n-1;i++) for(j=0;j<n-1-i;j++) if(s[j].sum<s[j+1].sum) { temp = s[j]; s[j] = s[j+1]; s[j+1] = temp; } for(i=0;i<n;i++){ if(i<=n*0.1-1) strcpy(s[i].level,"优秀"); else if(i<=n*0.5-1&&i>n*0.1-1) strcpy(s[i].level,"合格"); else strcpy(s[i].level,"不合格"); } }