#include#include using namespace std; bool cmp(int a, int b)//没有重复的为真 { int A[3], B[3]; int i=0, j; do { A[i] = a % 10; B[i] = b % 10; a /= 10; b /= 10; i++; } while (i < 3); for (i = 0; i < 3; i++) for (j = 0; j < 3; j++) if (A[i] == B[j]) return false; return true; } int main() { int i, j, k; int a[20], n = 0; for (i = 1; i <= 9; i++) { for (j = 0; j <= 9; j++) { if (i == j) continue; for (k = 0; k <= 9; k++) { if (k == j) continue; if (k == i) continue; int t = i * 100 + j * 10 + k; int t1 = sqrt(t); if (t1 * t1 == t) { a[n]=i*100+j*10+k; printf("%dn", a[n]); n++; } } } } for (i = 0; i < n; i++) for (j = 0; j < n; j++) if(cmp(a[i],a[j])) for (k =0; k < n; k++) if (cmp(a[k],a[j]) && cmp(a[k],a[i])) printf("%d %d %dn", a[i],a[j],a[k]); cin >> k; return 0; }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)