#include
#define N 3
struct Student
{
long num;
char name[20];
float score[3];
double aver;
};
int main ()
{
void input (struct Student stu[]);
struct Student max(struct Student stu[]);
void print(struct Student stu[]);
struct Student stu[N],*p=stu;
input(p);
print(max(p));
return 0;
}
void input(struct Student stu[])
{
int i;
printf("请输入各学生的信息:学号、姓名、三门功课:\n");
for(i=0;i {
scanf("%ld %s %f %f %f",&stu[i].num,&stu[i].name,&stu[i].score[0],&stu[i].score[1],&stu[i].score[2]);
stu[i].aver=(stu[i].score[0]+stu[i].score[1]+stu[i].score[2])/3.0;
}
}
struct Student max(struct Student stu[])
{
int m=0,i;
for(i=0;i {
if(stu[i].aver>stu[m].aver)
m=i;
return stu[m];
}
}
void print(struct Student stu)
{
printf("\n最高成绩的学生是:\n");
printf("学号:%d\n姓名:%s\n三门成绩:%5.1f,%5.1f,%5.1f\n平均成绩:%6.2f\n",stu.num,stu.name,stu.score[0],stu.score[1],stu.score[2],stu.aver);
}
问题:
Compiling...
day19.c
E:\cprogram\day19\day19.c(17) : error C2115: 'function' : incompatible types
E:\cprogram\day19\day19.c(17) : warning C4024: 'print' : different types for formal and actual parameter 1
E:\cprogram\day19\day19.c(27) : error C2018: unknown character '0xa3'
E:\cprogram\day19\day19.c(27) : error C2018: unknown character '0xac'
E:\cprogram\day19\day19.c(27) : error C2296: '&' : illegal, left operand has type 'long *'
E:\cprogram\day19\day19.c(27) : error C2297: '&' : illegal, right operand has type 'char [20]'
E:\cprogram\day19\day19.c(45) : warning C4028: formal parameter 1 different from declaration
Error executing cl.exe.
day19.obj - 5 error(s), 2 warning(s)
阅读(855) | 评论(0) | 转发(0) |