题目并不难
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <stdio.h> int is_cube(int n) { int i; if (n<=0) return 0; for (i=0; i<=1000000; i++) if (i*i*i == n) return i; return 0; } int main(int argc, char *argv[]) { int i; int a, b, c, d, t; /* for (i=0; i<=1000000; i++) if (is_cube(i)) printf("%d^3=%dn", is_cube(i),i); */ a = 18; for (b=2; b<=100; b++) for (c=b; c<=100; c++) { t = a*a*a - b*b*b - c*c*c; d = is_cube(t); if (d>=c) printf("%d %d %d %dn", a,b,c,d); } return 0; } |