Find passing greatly help

Category: C/C++ -> C Author: abc1234567890123435 Date: 2003-07-03 23:06:38
 
abc1234567890123435
2003-07-03 23:06:38
Khan! Compiler is not passed, find much help, preferably with red notes Ha!

# include <stdio.h>
typedef struct {
char name [20];
float mark [3];
int xuehao;
float average ;
} student;
student stu [10];

void printaverage ()
{
for (int i = 1; i <= 10; i + +)
{
float sum;
for (int k = 0; k <3; k + +)
{
sum + = stu [i-1]. mark [k];
}

; printf ("% s's average is% f \ n", stu [i-1]. name, sum/3.0);
stu [i-1]. average = sum/3.0;
}

}
void printmax ()
{int k;
float max = 0.0;
for (int i = 0; i <10 ; i + +)
{
if (stu [i]. average> max)
; {max = stu [i]. average;
k = i;
}

}

printf ("the max student is% s \ nhis mark is % f \ nhis xuehao is% d \ n ", stu [k]. name, max, stu [k]. xuehao);

}

; int main ()
{
printf ("************** please input every ; student's information ************** \ n \ n ");
for (int i = 1; i <= 10; i + +)
{printf ("\ n \ n");
printf (" student% d's name: ", i);
gets (stu [i-1]. name);
printf (" \ nplease input students % d's three marks: ", i);
scanf ("% f% f% f ", & stu [i-1]. mark [0], & stu [i-1]. mark [1], & stu [i-1]. mark [2]);
printf ("\ nplease input student% d's xuehao:" ;, i);
scanf ("% d \ n", & stu [i-1]. xuehao);
}
printaverage ();
printmax ();
return 0;

}
wfxiaohu
2003-07-03 23:24:26

#include<stdio.h>

typedef struct
{
char name[20];
float mark[3];
int xuehao;
float average;
} student;

student stu[10];

void printaverage()
{
for(int i=1;i<=10;i++)
{
float sum = 0.0;//
for(int k=0;k<3;k++)
{
sum+=stu[i-1].mark[k];
}
printf("%s's average is %f\n",stu[i-1].name,sum/3.0);
  stu[i-1].average= (float)sum / 3;
}
}

void printmax()
{
int k;
float max=0.0;
for(int i=0;i<10;i++)
{
if(stu[i].average>max)
{
max=stu[i].average;
k=i;
}
}
printf("the max student is %s\nhis mark is %f\nhis xuehao is %d\n",stu[k].name,max,stu[k].xuehao);
}


 int main()
 {
 printf("**************please input every student's information**************\n\n");
 for(int i=1;i<=10;i++)
 {
 printf("\n\n");
 printf("student%d's name:",i);
 gets(stu[i-1].name);
 fflush(stdin);
 printf("\nplease input students%d's three marks:",i);
 scanf("%f%f%f",&stu[i-1].mark[0],&stu[i-1].mark[1],&stu[i-1].mark[2]);
 printf("\nplease input student%d's xuehao:",i);
 scanf("%d",&stu[i-1].xuehao);//------------ \n
 fflush(stdin);//  enter
 }
 printaverage();
 printmax();
 return 0;



 }
szzk
2003-07-03 23:51:11
function did not declare ah
yhz564
2003-07-04 00:07:39
I was VC6.0 can run through
dgsdheryedfj
2003-07-04 00:47:38
compiler can live ah
zhangshi123456
2003-07-04 01:14:10
sweat! I use turbo c,

green, fflush (stdin) ;/ / absorption last enter
this is what ah? Never seen! Khan! ..........
bao193762
2003-07-04 01:41:53
VC6 ah well, where inappropriate ah, no way TC
this function definition is possible
zhaoliang052600
2003-07-04 02:09:03
I did not understand you say, Khan! ............
vwd
2003-07-04 02:45:47
vc6.0 can try the next, sweat, it seems I put turbo c threw it, but why the tc compiler does not pass it? Which greatly willing to help answer? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?