分析:枚举
条件:
1<a,b,c<=100;
a<=b;
a*a + b*b = c*c
枚举 a:2~100;b:a~100.
根据输出要求,先枚举a,再枚举b
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
#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; }