标题:看程序,不知道哪里错了,得不到结果
取消只看楼主
孙娜娜
Rank: 2
等 级:论坛游民
帖 子:49
专家分:22
注 册:2012-3-5
结帖率:93.75%
已结贴  问题点数:20 回复次数:1 
看程序,不知道哪里错了,得不到结果
//输出成绩较高学生的学号,姓名和分数
#include<stdio.h>
int main()
{
    struct Student
    {
        int num;
        char name[20];
        int score;
    }student1,student2;
     scanf("%d,%s,%d",&student1.num,&student1.name,&student1.score);
    scanf("%d,%s,%d",&student2.num,&student2.name,&student2.score);
    printf("The higher score is:\n");
    if (student1.score>=student2.score)
        printf("%d,%s,%d\n",student1.num,student1.name,student1.score);
               else
               printf("%d,%s,%d\n",student2.num,student2.name,student2.score);
               return 0;



           }
搜索更多相关主题的帖子: include 姓名 higher 
2012-06-02 20:14
孙娜娜
Rank: 2
等 级:论坛游民
帖 子:49
专家分:22
注 册:2012-3-5
得分:0 
回复 2楼 nzxiansheng
为什么把scanf改为:scanf("%d,%d,%s",&student1.num,&student1.score,student1.name);
                    scanf("%d,%d,%s",&student2.num,&student2.score,student2.name);
就可以了呢???      
      
2012-06-02 20:38



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-370679-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.091923 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved