首页 > 其他 > 详细

The sum of numbers form 0 to n.(20.9.2017)

时间:2017-09-24 20:01:44      阅读:278      评论:0      收藏:0      [点我收藏+]
#include <stdio.h>

int main() {
    int a,b,sum;
    printf("输入一个数字: ");
    scanf("%d",&a);                //输入数字a
    sum = 0;
    for(b=1;b<=a;b++){            //设置b=1 使用for loop,用b相加,一直加到输入的数字a的数值
        sum = sum + b;
    }
    printf("%d",sum);
}

 

The sum of numbers form 0 to n.(20.9.2017)

原文:http://www.cnblogs.com/RLeeH/p/7588227.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!