printf("100以内的偶数和为:%d\n",a);printf("100以内的奇数和为:%d\n",b);return0;}
}printf("1-100内的偶数和为:%d\n1-100内的奇数和为:%d\n",sum1,sum2);system("pause");return0;}
printf("奇数之和:%d\n偶数之和:%d\n",ji,ou);return0;}
C语言中用循环语句分别统计1到100的整数和,奇数和和偶数并输出include<stdio.h>intmain(intargc,char*argv[]){inti=0;intsum1=0;intsum2=0;intsum3=0;for(i=1;i<=...
i<=100;i++){if(i%2==0){s1=s1+i;g1=g1+1;}else{s2=s2+i;g2=g2+1;}};printf("偶数的个数为:%d\n偶数的和为:%d\n奇数的个数为:%d\n奇数的和为:%d\n",g1,s1,g2,s2);return0;}...
include<stdio.h>voidmain(){inti,s1=0,s2=0;for(i=1;i<=100;i++)(i%2)?s1+=i:s2+=i;printf("奇数之和:%d\n偶数之和:%d",s1,s2);}已调试。运行结果截图:...
参考代码如下:include<stdio.h>intmain(){inti,s1=0,s2=0,s=0;for(i=1;i<=100;++i){if(i%2==0)s2+=i;elses1+=i;s+=i;}printf("奇数和%d,偶数和%d,总和%d",s1,s2,s);return0;}...
+=i;}for(i=start+1;i<end+1;i+=2){even+=i;}}printf("总和为%d\n",result);printf("奇数和为%d\n",
C语言求100以内的奇数和,偶数和#include"stdio.h"voidmain(){inti,sum1=0,sum2=0;for(i=0;i<100;i++){if(i%2==0)sum2+=i;elsesum1+=i;}printf("sum1=%dsum2...
解法1:include<stdio.h>intF1(){return50*(1+99)/2;}intF2(){return50*(2+100)/2;}voidmain(){printf("Oddnumbersum=%d,Evennumbersum=%d\n",F1(),F2());}解法2include<stdio...