プログラムの実行結果は以下の通り。
Find: a:8, b:8
結果を図示すると以下のようになる。
ソースは以下の通り。
#include "puzutl.h" int main( int argc, cstring argv[]) { for( int a=1; a<= 9; a++) { for( int b=1; b<= 9; b++) { int x = (10*a+a)*(10*b+b); int c1 = (x/1000)%10; int c2 = (x/100)%10; int d1 = (x/10)%10; int d2 = (x/1)%10; if( c1 != c2 || d1 != d2) continue; int y = (10*c1+c2)*(10*d1+d2); int e1 = (y/1000)%10; int e2 = (y/100)%10; int f1 = (y/10)%10; int f2 = (y/1)%10; if( e1 == e2 && f1 == f2) { ps( "Find: a:%d, b:%d\n", a, b); } } } return 0; }