# include <stdio.h>
void main()
{
int i, n, sum1 = 0, sum2 = 0;
printf("请输入一个正整数:");
scanf("%d", &n);
for(i = 1; i <= n; i++)
{
if(i % 2 == 1)
sum1 += i;
else
sum2 += i;
}
printf("1到%d之间的奇数和为:%d\n", n, sum1);
printf("1到%d之间的偶数和为:%d\n", n, sum2);
评论