给你们看下5分钟完成的作业 ,别整天装
#define N 2
#include<stdio.h>
struct fw
{
int num;
char name[8];
int score1;
int score2;
int score3;
float total;
float aved;
};
main()
{
struct fw student[N];
float aves,maxnum,*temp=&aves;
int i,a=1;
char *maxname;
for(i=0;i<N;i++)
{scanf("%d",&(student[i].num));
scanf("%s",&(student[i].name));
scanf("%d",&(student[i].score1));
scanf("%d",&(student[i].score2));
scanf("%d",&(student[i].score3));
}
for(i=0;i<N;i++)
{
temp=average(a,&student[i]);
student[i].total=*temp;
}
a=2;
for(i=0;i<N;i++)
{
temp=average(a,&student[i]);
student[i].aved=*temp;
}
a=3;
temp=average(a,student);
aves=*temp;
maxnum=maximum(student);
for(i=0;i<N;i++)
if(maxnum==student[i].total)
*maxname=student[i].name;
printf("NO.
name
score1
score2
score3
total
average\n");
printf("=========================================================\n");
for(i=0;i<N;i++)
printf("%-6d%-9s%-9d%-9d%-9d%-8.0f%-7.2f\n",student[i].num,student[i].name,student[i].score1,student[i].score2,student[i].score3,student[i].total,student[i].aved);
printf("average=%-.2f\n",aves);
printf("The highest score:%s,score total:%.0f\n",*maxname,maxnum);
}
average(int a,struct fw *w)
{
int i;
float z=0.5,*fp=&z;
if(a==1)
{
*fp=(*w).score1+(*w).score2+(*w).score3;
}
if(a==2)
{
*fp=(*w).score1+(*w).score2+(*w).score3;
*fp=(*fp)/3;
}
if(a==3)
{
*fp=1;
for(i=0;i<N;i++)
*fp=*fp-1+(*(w+i)).aved;
*fp=*fp/N;
}
return(fp);
}
maximum(struct fw *y)
{
float f;
int i;
f=((*y).score1+(*y).score2+(*y).score3);
for(i=1;i<N;i++)
if(f<((*(y+i)).score1+(*(y+i)).score2+(*(y+i)).score3))
f=((*(y+i)).score1+(*(y+i)).score2+(*(y+i)).score3);
return(f);
}
谁都不是吃素的.可求你们做点事了, 我只是想看看大家的好的处理方法,我的太麻烦, 看你们把我说成什么了,真叫人生气.