码迷,mamicode.com
首页 > 其他好文 > 详细

直角三角形个数

时间:2014-07-27 10:11:02      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:

bubuko.com,布布扣
#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;

}

 

 


直角三角形个数

标签:

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!