4 条题解

  • 4
    @ 2022-12-30 10:07:46

    方法1:

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a, b, c, num = 0;
        cin >> a >> b >> c;
        if (a >= 16 && a <= 19)
        {
            num++;
        }
        if (b >= 60 && b <= 80)
        {
            num++;
        }
        if (c >= 165 && c <= 185)
        {
            num++;
        }
        if (num == 3)
        {
            cout << "Y";
        }
        else
        {
            cout << "N";
        }
        return 0;
    }
    

    方法2:

    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a, b, c;
        cin >> a >> b >> c;
        if (a >= 16 && a <= 19)
        {
            if (b >= 60 && b <= 80)
            {
                if (c >= 165 && c <= 185)
                {
                    cout << "Y";
                }
                else
                {
                    cout << "N";
                }
            }
            else
            {
                cout << "N";
            }
        }
        else
        {
            cout << "N";
        }
        return 0;
    }//已全部AC。
    

    点个赞呗!

    • 3
      @ 2024-2-17 10:43:25

      由函数组成的世界(连判断都是用参数来代替条件,就是注意要用布尔变量)~

      已AC,请放心食用

      #include <bits/stdc++.h>
      using namespace std;
      int age(int n)
      {
          if (n >= 16 && n <= 19)
          {
              return true;
          }
          else
          {
              return false;
          }
      }
      int weight(int n)
      {
          if (n >= 50 && n <= 80)
          {
              return true;
          }
          else
          {
              return false;
          }
      }
      int height(int n)
      {
          if (n >= 165 && n <= 185)
          {
              return true;
          }
          else
          {
              return false;
          }
      }
      void comp(bool a, bool b, bool c)
      {
          if (a && b && c)
          {
              cout << "Y";
          }
          else 
          {
              cout << "N";
          }
      }
      int main()
      {
          int a, b, c;
          cin >> a >> b >> c;
          comp(age(a), weight(b), height(c));
          return 0;
      }
      
      • 1
        @ 2023-4-6 21:52:00

        最简

        #include<bits/stdc++.h>
        using namespace std;
        int main()
        {
            int a,b,c;
            cin>>c>>b>>a;
            if (a>=165&&a<=185&&b>=50&&b<=80&&c>=16&&c<=19)
                cout<<"Y";
            else
                cout<<"N";
            return 0;
        }
        • 1
          @ 2023-3-19 17:33:09
          #include<bits/stdc++.h>
          using namespace std;
          int main()
          {
              int n, a, b, ans = 0;
              cin >> n >> a >> b;
              if(n >= 16&&n <= 19)
              {
                  ans++;
              }
              if(a >= 50 && n <= 80)
              {
                  ans++;
              }
              if(b >= 165 && b <= 185)
              {
                  ans++;
              }
              if(ans == 3)
              {
                  cout << "Y";
              }
              else
              {
                  cout << "N";
              }
              return 0;
          }
          
          • 1

          信息

          ID
          658
          时间
          1000ms
          内存
          16MiB
          难度
          2
          标签
          递交数
          101
          已通过
          64
          上传者