#include
typedef struct
{
char name[10];
char birth[11];
double chinese;
double english;
double math;
double ave;
}student;
void input(student *p,int n)
{
int i;
for(i=0;i{
printf("请输入第%d位学生信息:\n",i+1);
printf("姓名:");
scanf("%s",(p+i)->name);
printf("生日(格式:2000-1-1):");
scanf("%s",(p+i)->birth);
printf("语文成绩:");
scanf("%lf",&(p+i)->chinese);
printf("数学成绩:");
scanf("%lf",&(p+i)->math);
printf("英语成绩:");
scanf("%lf",&(p+i)->english);
(p+i)->ave=((p+i)->chinese+(p+i)->math+(p+i)->english)/3;
}
printf("输入完成!\n\n");
}
void output(student *p,int n)
{
int i;
printf("%10s%11s%9s%9s%9s%8s\n","姓名","生日","语文成绩","数学成绩","英语成绩","平均分");
for(i=0;i{
printf("%10s",(p+i)->name);
printf("%11s",(p+i)->birth);
printf("%9.0f",(p+i)->chinese);
printf("%9.0f",(p+i)->math);
printf("%9.0f",(p+i)->english);
printf("%8.2f\n",(p+i)->ave);
}
printf("输出完成!\n\n");
}
void sort(student *p,int n)
{
int i,j;
student t;
for(i=1;i{
for(j=1;j<=n-i;j++)
{
if((*(p+i)).ave>(*(p+i-1)).ave)
{
t=*(p+i);
*(p+i)=*(p+i-1);
*(p+i-1)=t;
}
}
}
printf("--------------排序完成!\n\n");
}
int main()
{
int n,i;
student stu[100];
printf("请输入人数:");
scanf("%d",&n);
input(stu,n);
sort(stu,n);
output(stu,n);
return 0;
}
以前写过类似的题目,你可以修改修改,就差不多是你题目要求了。
加我,我发给你1070295480