您的位置:首页 > 其它

数学趣题——具有特殊性质的数

2010-05-27 09:23 204 查看

1、题目

4位数abcd,有这样的性质:abcd=(ab+cd)的平方。ab,cd都为两个2位数,求这个4位数abcd。

2、源码

[code] #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\t", a, b, c, d);
}
}
int main()
{
 printf("There are following numbers according with the condition\n");
 func();
 return 0;
}
[/code]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: