/* Name:N以内的勾股数 Author:Dualeak Blog:http://blog.csdn.net/dualeak Date:2009-11-07 Description: 输出满足c < n, a^2 + b^2 = c^2 的所有正整数a, b, c. */ #include <stdio.h> #include <math.h> int main(void) { unsigned long n, a, b ,c, i=0; scanf("%lu", &n); for(a=1; a<=n; a++){ for(b=a; b<=n; b++){ for(c=b; c<=n; c++){ if(c*c == a*a + b*b){ i++; printf("%lu^2 + %lu^2 = %lu^2/n", a, b, c); } } } } printf("i=%lu/n", i); return 0; }