看不懂,谁会
看不懂,谁会?
#include<stdio.h>
int main()
/*{
int sum=0;
int i=1;
int flag=0;
while(i<=100)
{
if(i%2==0)
{
sum=i*-1;
}
else
{
sum=i*1;
}
flag+=sum;
i++;
}
printf("sum=%d\n",flag);
return 0;
}*/
{
int sum = 0;
int i = 1;
while(i<=100)
{
if(i%2!=0)
{
sum+=i;
}
else
{
sum-=i;
}
i++;
}
printf("sum=%d\n",sum);
return 0;
}
int jjjjjjjj()
{
int sum = 0;
int i = 1;
do
{
if(i%2!=0)
{
sum+=i;
}
else
{
sum-=i;
}
i++;
}
while(i<=100);
printf("sum=%d\n",sum);
return 0;
}
int kkkkkkkk()
{
int sum = 0;
int i;
int flag = 1;
for(i=1;i<=100;i++)
{
if(i%2==0)
{
sum-=i;
}
else
{
sum+=i;
}
}
printf("sum=%d\n",sum);
return 0;
}
举报