zoukankan      html  css  js  c++  java
  • 直角三角形个数

    #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;

    }


  • 相关阅读:
    HBase常用Shell命令
    在Eclipse中创建Maven多模块项目
    在IntelliJ IDEA中创建Maven多模块项目
    在IntelliJ IDEA中创建Web项目
    【Python】如何安装easy_install?
    RabbitMQ从入门到精通
    Erlang语言入门
    Eclipse背景颜色改动
    导出Excel1
    计算机概述
  • 原文地址:https://www.cnblogs.com/wc1903036673/p/3870545.html
Copyright © 2011-2022 走看看