c语言
用DO While 求解 你是想让别人给你做题吧?还是自己多动手 #include <stdio.h>int main(void) {
int a, b, temp;
int sum = 0;
printf("请输入两个整数。\n");
printf("整数a:");
scanf("%d", &a);
printf("整数b:");
scanf("%d", &b);
if (a > b) { //将a,b排序,从小到大
temp = a;
a = b;
b = temp;
}
temp = a;
do { //从小值开始累加
sum = temp + sum;
temp++;
} while (temp <= b);
printf("大于等于%d小于等于%d的所有整数和是%d\n", a, b, sum);
return 0;
}
页:
[1]