#include <stdio.h>
int main()
{
int a = 1;
int sum = 0;
while (a <= 100)
{
sum = sum + a;
a++;
}
printf("总和=%d\n", sum);
return 0;
}
#include <stdio.h>
int main()
{
int a = 0;
int sum = 0;
{
for (a = 1; a <= 100; a++)
sum += a;
}
printf("总和=%d", sum);
return 0;
}
# include <stdio.h>
int main()
{
int a = 0;
int sum1 = 0;
int sum2 = 0;
int sum3 = 0;
for (a = 1; a <= 100; a++)
{
if (a % 2 == 0)
sum1 = sum1 + a;
else
sum2 = sum2 + a;
}
sum3 = sum2 + sum1;
printf("总和=%d\n", sum3);
return 0;
}
标签:语句,include,int,sum,sum3,while,100,main
From: https://blog.51cto.com/u_16150211/6435075