c语言中计算两个整数之间的所有整数的和

 

1、

#include <stdio.h>

int main(void)
{
    int a,b;
    puts("please input two integers.");
    printf("a = "), scanf("%d", &a);
    printf("b = "), scanf("%d", &b);
    int sum = 0;
    do
    {
    
        sum = sum + b;
        b = b + 1;
        
    }
    while (b <= a );
    printf("sum = %d.\n", sum);
    return 0;
}

 

上一篇:2020 BIT冬训-模拟与暴力 J - The Artful Expedient CodeForces - 869A


下一篇:链表