直角三角形个数

#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\n",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\n",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;

}

 

 


posted @ 2014-07-26 20:38  博园少主  阅读(399)  评论(0编辑  收藏  举报