cjqiuzhi 2021-08-05 10:32 采纳率: 33.3%
浏览 30
已结题

程序编译有错误,但是不知道错误在哪,希望比我厉害指导指导我?

#include<stdio.h>
#define N 3
struct student
{
int num;
char name[20];
float score[3],aver;
}a;
int main()
{
void input(struct student stu[]);
void print(struct student stu[]);
struct student max(struct student stu[]);
struct student stu[N];
input(stu);
a=max(stu);
print(a);
return 0;
}
void input (struct student stu[])
{
int i;
printf("请输入各学生的信息:学号,姓名,3门课成绩:\n");
for(i=0;i<N;i++)
{
scanf("%d %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;
}
}
struct student max(struct student stu[])
{
int m=0;
int i;
for(i=0;i<N;i++)
if(stu[i].aver>stu[m].aver)
m=i;
return stu[m];
}
void print(struct student stu[])
{
printf("成绩最高的学生是:");
printf("学号:%d\n姓名:%s\n三门成绩:%5.1f,%5.1f,%5.1f\n平均成绩:%6.1f",stu.num,stu.name,stu.score[0],stu.score[1],stu.score[2],stu.aver);

}

  • 写回答

3条回答 默认 最新

  • -朽木 2021-08-05 10:40
    关注

    错误太多:

    1. 最后的printf里面逗号是中文的,改成英文。
    2. main函数里面print(a),这句话是错误的,c语言没有print
    3. 还有好多错,好好学习吧。
    #include <stdio.h>
    #define N 3
    struct student
    {
       int num;
       char name[20];
       float score[3], aver;
    } a;
    int main()
    {
       void input(struct student stu[]);
       void print(struct student stu);
       struct student max(struct student stu[]);
       struct student stu[N];
       input(stu);
       a = max(stu);
       print(a);
       return 0;
    }
    void input(struct student stu[])
    {
       int i;
       printf("请输入各学生的信息:学号,姓名,3门课成绩:\n");
       for (i = 0; i < N; i++)
       {
          scanf("%d %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;
       }
    }
    struct student max(struct student stu[])
    {
       int m = 0;
       int i;
       for (i = 0; i < N; i++)
       {
              if (stu[i].aver > stu[m].aver)
              {
                  m = i;
              }
       }
       return stu[m];
    }
    void print(struct student stu)
    {
       printf("成绩最高的学生是:");
       printf("学号:%d\n姓名:%s\n三门成绩:%5.1f,%5.1f,%5.1f\n平均成绩:%6.1f",stu.num, stu.name, stu.score[0], stu.score[1], stu.score[2], stu.aver);
    }
    
    
    本回答被专家选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 8月16日
  • 专家已采纳回答 8月8日
  • 创建了问题 8月5日

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器