#include <stdio.h>
int main()
{
int sum = 0;
int sum1 = 0;
for (int num = 1; num <= 100; num += 2) {
sum += num;
printf("奇数和为%d\n",sum);
}
for (int num1 = 2; num1 <= 100; num1 += 2) {
sum1 += num1;
printf("偶数和为%d\n", sum1);
}
return 0;
}
for循环计算100以内的奇偶和。
标签:奇偶,写个,int,sum,num,main,循环 From: https://blog.51cto.com/u_16253936/7428878