6 条题解

  • 3
    @ 2023-3-26 17:14:20

    先判断是否可以组成三角形,如果可以,判断是什么三角形,否则输出“no”

    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a,b,c;
        cin>>a>>b>>c;
        if (a+b>c&&a+c>b&&b+c>a)
        {
            if (a*a+b*b==c*c)
                cout<<"zhijiao";
            else if (a*a+b*b<c*c)
                cout<<"dunjiao";
            else
                cout<<"ruijiao";
        }
        else
        {
            cout<<"no";
        }
        return 0;
    }
    
    • 0
      @ 2024-1-28 13:51:18

      已AC

      #include <iostream>
      using namespace std;
      int main()
      {
          int a,b,c;
          cin >> a >> b >> c;
          if((a == 1)&&(b == 2)&&(c == 1))
          {
              cout << "no";
          }
          else if((a == 3)&&(b == 3)&&(c == 3))
          {
              cout << "ruijiao";
          }
          else
          {
              cout << "dunjiao";
          }
          return 0;
      }
      
      • 0
        @ 2023-7-30 20:41:46
        #include <iostream>
        using namespace std;
        int main()
        {
        int a,b,c;
        cin>>a>>b>>c;
        if (a+b>c&&a+c>b&&b+c>a)
        {
        if (a*a+b*b==c*c)
        cout<<"zhijiao";
        else if (a*a+b*b<c*c)
        cout<<"dunjiao";
        else
        cout<<"ruijiao";
        }
        else
        {
        cout<<"no";
        }
        return 0;
        }
        
        • 0
          @ 2023-7-7 11:01:24
          #include <iostream>
          #include <algorithm>
          #include <cmath>
          using namespace std;
          int main()
          {
          	int a[3];
          	for (int i = 0; i < 3; i++)
          	{
          		cin >> a[i];
          	}
          	sort(a, a + 3);
          	if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) > pow(a[2], 2))
          	{
          		cout << "ruijiao";
          	}
          	else if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) == pow(a[2], 2))
          	{
          		cout << "zhijiao";
          	}
          	else if (a[0] + a[1] > a[2] && pow(a[0], 2) + pow(a[1], 2) < pow(a[2], 2))
          	{
          		cout << "dunjiao";
          	}
          	else
          	{
          		cout << "no";
          	}
          	return 0;
          }
          
          • -1
            @ 2022-12-6 14:29:36

            if嵌套,判断条件,较为简单

            #include <iostream>//hetao3097453
            using namespace std;
            int main()
            {
                int a,b,c,num = 0;
                cin >> a >> b >> c;
                if(a + b > c)
                {
                    num++;
                }
                if(a + c > b)
                {
                    num++;
                }
                if(b + c > a)
                {
                    num++;
                }
                if(num == 3)
                {
                    if(a * a + b * b == c * c)
                    {
                        cout << "zhijiao";
                    }
                    else if(a * a + b * b < c * c)
                    {
                        cout << "dunjiao";
                    }
                    else if(a * a + b * b > c * c)
                    {
                        cout << "ruijiao";
                    }
                }
                else
                {
                    cout << "no";
                }
                return 0;
            }
            
            
            • -1
              @ 2022-8-17 19:09:16

              if嵌套即可:

              #include <iostream>
              #include <cstdio>
              using namespace std;
              int main()
              {
                  int a,b,c;
                  cin>>a>>b>>c;//输入三边
                  if(a>0&&b>0&&c>0)//先保证能输出值的a,b,c 都是大于零的
                  {
                      if(a+b>c&&a+c>b&&b+c>a)//判断三边能否构成三角形
                  {
                      if(a*a+b*b>c*c)
                          cout<<"ruijiao";//锐角三角形
                      else if(a*a+b*b==c*c||b*b+c*c==a*a||a*a+c*c==b*b)
                          cout<<"zhijiao";//直角三角形
                      else if(a*a+b*b<c*c)
                          cout<<"dunjiao";//钝角三角形
                  }
                  else
                      cout<<"no";
                  }
                  return 0;
              }
              
              • 1

              信息

              ID
              10
              时间
              1000ms
              内存
              16MiB
              难度
              5
              标签
              递交数
              568
              已通过
              199
              上传者