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

Posted RLee

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了The sum of numbers form 0 to n.(20.9.2017)相关的知识,希望对你有一定的参考价值。

#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)的主要内容,如果未能解决你的问题,请参考以下文章

The Sum of 0 for four numbers(拆解加二分思想)

Leetcode-1085 sum of digits in the minimum number(最小元素各数位之和)

[CF1598G]The Sum of Good Numbers

[Algorithm] A nonrecursive algorithm for enumerating all permutations of the numbers {1,2,...,n}(代码片

huggingface | how to get the params‘ number of a model

1104 Sum of Number Segments (20)