程序设计俱乐部看到的:
自己又想了想,代码也比较简单吧:
#include<iostream> using namespace std; int fun(int a=0,int b=5) { return (a+b); } bool bad(int a,int b,int c) { return a+b<c; } int main() { for (int c=1; c<50; c++) { for (int b=1; b<100; b++) { for (int a = b>c?(b+1):(c+1); a<100; a++) { if (bad(c,b,a)) break; if (a*a == b*b + c*c) { printf ("%d^2 = %d^2 + %d^2\n", a, c, b); printf ("%d^2 = %d^2 + %d^2\n", a, b, c); } } } } }