C语言编程问题。求指错。随便问一下定义的时候在哪些情况下需要给变量赋初值

题目:编写程序求出满足下列条件的四位数:该数是个完全平方数;千位、十位数字之和为10,百位、个位数字之积为12。

#include <stdio.h>
main()
{
int a,b,c,d,e,i=0;
for(i=1000;i<10000;i++)
a=i/1000;
b=i/100%10;
c=i/10%10;
d=i%10;
for(e=30;e<100; e++)
if(i==e*e && a+c==10 && c*d==12)
printf("%5d\n",i);
}

第1个回答  2011-12-05
if(i==e*e && a+c==10 && c*d==12)
这个判断应该是b*d==12,是百位和个位乘积
第2个回答  2011-12-05
#include <stdio.h>
main()
{
int a,b,c,d,e,i=0;
for(i=1000;i<10000;i++)
{ a=i/1000;
b=i/100%10;
c=i/10%10;
d=i%10;
for(e=30;e<100; e++)
if(i==e*e && a+c==10 && b*d==12)
printf("%5d\n",i);
}
}
第3个回答  2011-12-05
我改了一下,你循环语句应用{}
#include <stdio.h>
main()
{
int a,b,c,d,e,i;
for(i=1000;i<10000;i++)
{
a=sqrt(i);
b=i/1000;
c=i%1000/100;
d=i%100/10;
e=i%10;
if(i==a*a&&b+d==10&&c*e==12 )
printf("%d",i) ;
}本回答被提问者采纳
第4个回答  2011-12-05
你不在for后面跟个大括号、、、电脑怎么晓得后面几行都归for管追问

知道了。。嘿嘿。。谢谢指教

第5个回答  2011-12-05
for循环都没有花括号吗?
相似回答