现在的位置: 首页 > 综合 > 正文

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

2013年01月10日 ⁄ 综合 ⁄ 共 506字 ⁄ 字号 评论关闭

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

    }

}

抱歉!评论已关闭.