标题:<求助>编程问题
只看楼主
shodawn
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2016-3-1
结帖率:100%
已结贴  问题点数:20 回复次数:3 
<求助>编程问题
求多个整数和,输入非数字才开始求和,帮我看看
#include<stdio.h>
int main()
{
    int sum=0,value=0;
    while(scanf("%d",&value))
    {
        sum+=value;
    }
    printf("%d",sum);
    return 0;
}
搜索更多相关主题的帖子: return 
2016-03-01 19:51
yangfrancis
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:141
帖 子:1510
专家分:7661
注 册:2014-5-19
得分:7 
运行无误
2016-03-01 20:23
rjsp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:507
帖 子:8890
专家分:53117
注 册:2011-1-18
得分:7 
    while(scanf("%d",&value))
    {
        sum+=value;
    }
你是如何结束这个循环的?

“输入非数字才开始求和” --- 这是你的要求呢,还是你想解决掉的bug?
2016-03-02 08:24
农民工
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:21
帖 子:109
专家分:639
注 册:2015-8-22
得分:7 
有什么问题吗?
Return Value

Both scanf and wscanf return the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. The return value is EOF for an error or if the end-of-file character or the end-of-string character is encountered in the first attempt to read a character.

2016-03-03 15:53



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




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

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