题目要求:
有这样一个4位数正数abcd,它具有这样的性质abcd=(ab+cd)2,其中ab和cd为两个2位数,求这个4位数abcd。
#include "stdio.h"
void func()
{
int a,b,c,d;
for(a=1;a<=9;a++)
for(b=0;b<=9;b++)
for(c=0;c<=9;c++)
for(d=0;d<=9;d++)
{
if(a*1000+b*100+c*10+d == ((a*10+b) +(c*10+d))*
((a*10+b) +(c*10+d)))
printf("%d%d%d%d ",a,b,c,d);
}
}
main()
{
printf("There are following numbers according with the condition
");
func();
getche();
}运行结果:
运行结果
| 留言与评论(共有 0 条评论) “” |