输入月份,显示天数(C++)

    技术2022-05-20  28

    #include <iostream>

    using namespace std;

    int main()

    {

      int month;

      do

      {

          cout<<"Enter a number of month:"<<endl;

          cin>>month;

          if(month<=0||month>12)

             {

                  cout<<"please check it again!"<<endl;

             }

      }while(month<=0||month>12)

     switch(month)

        {

            case 2:

                cout<<"28 or 29 days"<<endl;

                   break;

            case 4:

            case 6:

            case 9:

            case 11:

                 cout<<"30 days"<<endl;

                    break;

            default:

                 cout<<"31 days"<<endl;

                    break;

        }

    }


    最新回复(0)