2 条题解

  • 1
    @ 2022-11-27 15:27:49
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int a, n;
        cin >> a >> n;
        if (a % 400 == 0)
        {
            if (n == 2)
            {
                cout << "29";
            }
            else if (n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12)
            {
                cout << "31";
            }
            else
            {
                cout << "30";
            }
        }
        else if (a % 4 == 0 && a % 100 != 0)
        {
            if (n == 2)
            {
                cout << "29";
            }
        }
        else if (n == 2)
        {
            cout << "28";
        }
        if (n == 1 || n == 3 || n == 5 || n == 7 || n == 8 || n == 10 || n == 12)
        {
            cout << "31";
        }
        else if (n == 4 || n == 6 || n == 9 || n == 11)
        {
            cout << "30";
        }
        return 0;
    }
    
    • 0
      @ 2023-4-9 19:30:30

      跟P1092一摸一样

      #include<bits/stdc++.h>
      using namespace std;
      int main()
      {
          int x,y;
          cin>>x>>y;
          if (y==2)
              if (x%4==0&&(x%400==0||x%100!=0))
                  cout<<29;
              else
                  cout<<28;
          else
              if (y==1||y==3||y==5||y==7||y==8||y==10||y==12)
                  cout<<31;
              else
                  cout<<30;
          return 0;
      }
      • 1

      【入门】判断某年某月的天数

      信息

      ID
      821
      时间
      1000ms
      内存
      16MiB
      难度
      2
      标签
      递交数
      70
      已通过
      44
      上传者