请问一下我哪里出错了
怎么我会输出相同的数字?
#include<stdio.h>
int main()
{
int a,b,c,x;
for(a=1;a<=9;a++)
{
for(b=0;b<=9;b++)
for(c=0;c<=9;c++)
if(a*100+b*10+c==a*a*a+b*b*b+c*c*c)x=a*a*a+b*b*b+c*c*c;
printf("%d\n",x);
}
return 0;
}
[解决办法]
int a,b,c,x;for(a=1;a<=9;a++){for(b=0;b<=9;b++)for(c=0;c<=9;c++)if(a*100+b*10+c==a*a*a+b*b*b+c*c*c) { x=a*a*a+b*b*b+c*c*c; printf("%d\n",x); }}
[解决办法]
int main(){ int a, b, c, x; for (a = 1; a <= 9; a++) { for (b = 0; b <= 9; b++) { for (c = 0; c <= 9; c++) { if (a * 100 + b * 10 + c == a * a * a + b * b * b + c * c * c) { x = a * a * a + b * b * b + c * c * c; printf("%d\n", x); } } } } return 0;}