注册 登录
编程论坛 C语言论坛

问问有关结构体的题

九笙 发布于 2019-12-10 11:00, 1513 次点击
只有本站会员才能查看附件,请 登录

题目如图
然后这是我的代码
#include <stdio.h>
struct student
{
    int id[2];
    char name[2];
    int score[2];
};
int main()
{
    int i;
    struct student stu[2];
    for(i=0;i<2;i++)
    {
       scanf("%d%s%d",&stu[i].id,stu[i].name,&stu[i].score);
    }
    if(stu[0].score<stu[1].score)
    {
        printf("%d %s %d",stu[1].id,stu[1].name,stu[1].score);
    }
    else
    printf("%d %s %d",stu[0].id,stu[0].name,stu[0].score);
    return 0;
}
只有本站会员才能查看附件,请 登录

然后结果就是这样QVQ  求助
2 回复
#2
九笙2019-12-10 11:18
单纯数字的输出也有问题,问问为什么
#3
九笙2019-12-10 12:04
我知道了,犯傻了,已解决
1