由二个平方三位数获得三个平方二位数。已知两个平方三位数abc和xyz,其中未必是不同的;而ax、by、cz是三个平方二位数。请编程求三位数abc和xyz。
**输出格式要求:"The possible perfect squares combinations are:\n" " %d and %d\n"
程序运行示例如下:
The possible perfect squares combinations are:
400 and 900
841 and 196
#include<stdio.h>
#include<math.h>
int main()
{
int x=10,y=10;
int i,t;
float a,b,c;
printf("The possible perfect squares combinations are:\n");
for(x;x<=31;x++)
for(y;y<=31;y++)
{
i=x*x;t=y*y;
a=(float)(i/100+t/100);
b=(float)(i/10%10+t/10%10);
c=(float)(i%10+t%10);
if((sqrt(a)-(int)sqrt(a)==0)&&(sqrt(b)-(int)sqrt(b)==0)&&(sqrt(c)-(int)sqrt(c)==0))
printf("" " %d and %d\n",i,t);
}
return 0;
}
for(x=10;x<=31;x++)
for(y=10;y<=31;y++)
printf(" %d and %d\n",i,t);