我这样有什么不对?
#include <stdio.h>
int main()
{
int sum = 0;
int i = 1;
int flag = 1;
while(i<=100)
{
i++;
sum=sum+i*flag;
flag=-flag;
}
printf("sum=%d\n",sum);
return 0;
}
#include <stdio.h>
int main()
{
int sum = 0;
int i = 1;
int flag = 1;
while(i<=100)
{
i++;
sum=sum+i*flag;
flag=-flag;
}
printf("sum=%d\n",sum);
return 0;
}
2020-10-26
举报