分析:枚举

条件:

  1<a,b,c<=100;

      a<=b;

      a*a + b*b = c*c

  枚举 a:2~100;b:a~100.

  根据输出要求,先枚举a,再枚举b 

#include<cstdio>
#include<cmath>
int main(){
    int a,b,c;
    for (int a=2;a<=100;a++)
        for(int b=a;b<=100;b++){
            int c=floor(sqrt(a*a+b*b)+0.5);
            if(c*c==a*a+b*b&&c<=100)printf("%d*%d + %d*%d = %d*%d\n",a,a,b,b,c,c);
        }            
    return 0;
}
View Code