哪里错了 求大佬指点
#include <stdio.h>
int main()
{
int sum = 0; //定义计算结果变量sum
int i = 1; //定义循环数字变量i
int flag = 1; //定义符号状态变量flag
i = 1; //重新初始化变量i
for(i=1;i<=100;i++)
{
sum == sum + i*flag;
flag ==flag*(-1);
}
printf("sum=%d\n",sum);
return 0;
}
#include <stdio.h>
int main()
{
int sum = 0; //定义计算结果变量sum
int i = 1; //定义循环数字变量i
int flag = 1; //定义符号状态变量flag
i = 1; //重新初始化变量i
for(i=1;i<=100;i++)
{
sum == sum + i*flag;
flag ==flag*(-1);
}
printf("sum=%d\n",sum);
return 0;
}
2019-10-23
举报