C/C++の宿題を片付けます 58代目
■ このスレッドは過去ログ倉庫に格納されています
0208デフォルトの名無しさん
2006/01/20(金) 00:56:46#include <stdio.h>
#include <math.h>
int match(int y){
int flg = 0;
if(y<123456789||987654321<y) return 0;
while(y){
int p = 1<<(y%10);
if(p&1||flg&p) return 0;
flg|=p;
y/=10;
}
return 1;
}
main(){
int begin = (int)floor(sqrt(123456789));
int end = (int)ceil(sqrt(987654321));
int x;
for(x=begin; x<end; ++x) if(match(x*x)) printf("y=%d x=%d\n", x*x, x);
}
■ このスレッドは過去ログ倉庫に格納されています