#include
main()
{
int s1,s2,i;
s1=s2=0;
for(i=1;i<=100;i++)
if(i%2==0) s1+=i;else s2+=i;
printf("偶数和是:%d\n奇数和是:%d\n",s1,s2)
}
#include
void main()
{
int s1,s2, i=1,j=2;
int sum1=sum2=0;
while(i<100)
{
sum1+=i;
i=i+2;
}
while(j<=100)
{
sum2+=j;
j=j+2;
}
cout<<"奇数:"<
VB
?
public class qita {
public static void main(String[] args) {
long sum01 = 0;
long sum02 = 0;
for(int i=0;i<=100;i++){
if(i%2 == 0)
sum01 += i;
else sum02 += i;
}
System.out.println("1-100偶数和是" + sum01);
System.out.println("1-100奇数和是" + sum02);
}
}