发布网友 发布时间:2022-05-26 13:22
共1个回答
热心网友 时间:2023-10-19 06:24
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 300
typedef struct ss{
char name[80];
double height;
int weight;
double scholar;
} student;
void input(student a[],int n);
void output(student a[],int n);
void sort(student a[],int n);
int main(){
student a[N],m,t;
int i,len,j;
printf("人数:");
scanf("%d",&len);
input(a,len);
output(a,len);
sort(a,len);
output(a,len);
return EXIT_SUCCESS;
}
void input(student a[],int n){
int i;
for (i = 0; i <n; i++){
printf("输入第%d个娃的姓名\n",i+1);scanf("%s",a[i].name);
printf("输入第%d个娃的身高,体重,奖金:\n",i+1);
scanf("%lf%d%lf",&a[i].height,&a[i].weight,&a[i].scholar);
}
}
void output(student a[],int n){
int i;
for (i = 0; i <n; i++){
printf("%s %.1lf %d %.1lf",a[i].name,a[i].height,a[i].weight,a
[i].scholar);printf("\n");
}
printf("\n");
}