请问哪里有问题?问什么一直输出-2
#include <stdio.h>
int main()
{
int sum = 0;
int i = 1;
int flag = 1;
while(i<=100)
{
i++;
sum= i*flag+sum;
flag=(-1)*flag;
printf("sum=%d",sum);
return 0;
}
}
#include <stdio.h>
int main()
{
int sum = 0;
int i = 1;
int flag = 1;
while(i<=100)
{
i++;
sum= i*flag+sum;
flag=(-1)*flag;
printf("sum=%d",sum);
return 0;
}
}
2020-10-07
举报