请问大佬我这样错在哪了
#include <stdio.h>
int main()
{
int sum = 0; //定义计算结果变量sum
int i = 1; //定义循环数字变量i
int flag = 1; //定义符号状态变量flag
do
{
i++;
sum+=i*flag;
flag*=-1;
}while(i<=100);
printf("sum=%d\n",sum);
return 0;
}
#include <stdio.h>
int main()
{
int sum = 0; //定义计算结果变量sum
int i = 1; //定义循环数字变量i
int flag = 1; //定义符号状态变量flag
do
{
i++;
sum+=i*flag;
flag*=-1;
}while(i<=100);
printf("sum=%d\n",sum);
return 0;
}
2019-03-15
举报