标签:++i class sum turn 偶数 ++ ret printf pre
1 #include <stdio.h> 2 3 int main (void) 4 { 5 int i; 6 int sum1 = 0;//奇数和 7 int sum2 = 0;//偶数和 8 9 for (i = 1; i<101; ++i) 10 11 if (i%2 == 1) 12 { 13 sum1 += i; 14 } 15 else 16 { 17 sum2 += i; 18 } 19 printf("1到100的奇数之和 = %d\n",sum1); 20 printf("1到100的偶数之和 = %d\n",sum2); 21 22 23 24 return 0; 25 }
#include <stdio.h>
int main (void){int i;int sum1 = 0;//奇数和int sum2 = 0;//偶数和for (i = 1; i<101; ++i)if (i%2 == 1){sum1 += i;}else{sum2 += i;}printf("1到100的奇数之和 = %d\n",sum1);printf("1到100的偶数之和 = %d\n",sum2);return 0;}
标签:++i class sum turn 偶数 ++ ret printf pre
原文地址:https://www.cnblogs.com/a188/p/12374126.html