#include <stdio.h>
int main()
{
int a=1,int b=2,int c;
for(;a<=999;a=c,b++)
{
c=a*b;
}
printf("%d",c);
return 0;
}
错误描述
expected gcc [行4,列14]
'c' undeclared (first use in this function) gcc [行5,列19]
'b' undeclared (first use in this function) gcc [行5,列21]
left-hand operand of comma expression has no effect [-Wunused-value] gcc [行5,列20]
#include <stdio.h>
int main()
{
int a=1,b=2,c;
for(;a<=999;a=c,b++)
{
c=a*b;
}
printf("%d",c);
return 0;
}
定义变量出了问题,int a,b,c就可以了,你用了多个int
你这样定义:
int a=1,b=2,c;
就行
想用多个 int 得分行,这样看起来也简洁
#include <stdio.h>
int main()
{
int a = 1;
int b = 2;
int c;
for (; a <= 999; a = c, b++)
{
c = a * b;
}
printf("%d", c);
return 0;
}