输入月份,显示天数C++
#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; } }