实验六

part1

#include 

const int N=5;

typedef struct student {
    long no;
    char name[20];
    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 stu[N], minlist[N];
    int count;
    
    printf("录入%d个学生信息\n", N);
    input(stu, N);
    
    printf("\n统计最低分人数和学生信息...\n");
    count = findMinlist(stu, minlist, N);
    
    printf("\n一共有%d个最低分,信息如下:\n", count);
    output(minlist, count);
     
    return 0;
} 
 
void input(STU s[], int n) {
    int i;
    for(i=0; i) 
        scanf("%ld %s %d", &s[i].no, s[i].name, &s[i].score);
} 

void output(STU s[], int n) {
    int i;
    for(i=0; i)
        printf("%ld %s %d\n", s[i].no, s[i].name, s[i].score); 
} 


int findMinlist(STU s[], STU t[], int n) {
    int i,j,k=0,count=0;
    STU temp;
    for(i=0;i){
        for(j=i;j){
            if(s[j].score<s[i].score){
                temp=s[i];
                s[i]=s[j];
                s[j]=temp;
            }
        }
    }
    t[k]=s[count];
    while(t[k].score==s[++count].score)
        t[++k]=s[count];
    return count; 
} 实验六_第1张图片

part2

#include 
#include <string.h>
const int N = 10;

typedef struct student {
    long int id;
    char name[20];
    float objective;
    float subjective;    
    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); 
    
    return 0;
} 

void input(STU s[], int n) {
    int i;
    for(i=0;i)
       scanf("%d %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){
       printf("%5d %10s %5.1f %5.1f %5.1f %10s\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,k,m=0;
    STU temp;
    for(i=0;i)
        s[i].sum=s[i].objective+s[i].subjective;
    for(j=0;j){
        for(k=j;k){
            if(s[j].sum<s[k].sum){
                temp=s[j];
                s[j]=s[k];
                s[k]=temp;
            }
        }
    }
    while(m<=n){
        if(m<=n*0.1-1)
        strcpy(s[m].level,"优秀");
        else if(m>n*0.1-1&&m<=n*0.5-1)
        strcpy(s[m].level,"合格");
        else
        strcpy(s[m].level,"不合格"); 
        m++;
    };    
}
实验六_第2张图片

 

你可能感兴趣的:(实验六)