直角三角形个数

#include <iostream>
using namespace std;
int main( )
{    int a,b,c;
   for (a=1; a<20; a++)
      for (b=1; b<20; b++)
         for (c=1; c<=20; c++)
          if (a*a+b*b==c*c)    
                        printf("a=%d,b=%d,c=%d
",a,b,c);
      system("pause");    return 1;
}     
View Code
#include <iostream>
using namespace std;
int main( )
{    int a,b,c;
   for (a=1; a<20; a++)
      for (b=1; b<20; b++)
         for (c=1; c<=20; c++)
          if (a*a+b*b==c*c)    
                        printf("a=%d,b=%d,c=%d
",a,b,c);
      system("pause");    return 1;
}     

 #include <iostream>
using namespace std;
int main( )

  int a,b,c;
    for (a=1; a<20; a++)
    for (b=a; b<20; b++)
      for (c=b; c<=20; c++)


   if (a*a+b*b==c*c) 
                            cout<<"a="<<a<<"  b="<<b<<"  c="<<c<<endl;
   system("pause"); return 1;

********************************************************************************

#include <iostream>

#include<math.h>

using namespace std; int main( )

{   int a,b,c;     

   for (a=1; a<20; a++)    

for (b=a+1; b<20; b++)   

   {          c=sqrt(a*a+b*b);

 if (a*a+b*b==c*c)

cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;

}

  return 1;

}


原文地址:https://www.cnblogs.com/wc1903036673/p/3870545.html