#include <stdio.h>
#include <stdlib.h>
int sum(int a,int b)
{
int sum=0;
int i;
for(i=a;i<=b;i++)
{sum+=i;
}
printf("从%d到%d的和为%d\n",a,b,sum);
}
int main()
{
int x;
int y;
printf("请输入两个数:\n");
scanf_s("%d%d",&x,&y);
sum(x,y);
system("pause");
}
09-29
1325
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-24
881
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)