65,211
社区成员
发帖
与我相关
我的任务
分享#include <iostream>
using namespace std;
typedef struct
{
short month;
} time ;
int main(void)
{
time t;
cout <<"Month:" <<endl;
cin>>t.month ;
if(t.month==1||t.month==2||t.month==3||t.month==4||t.month==5||t.month==6||t.month==7||t.month==8||t.month==9||t.month==10||t.month==11||t.month==12)
cout<<"The data you just input is right!"<<endl;
else
cout<<"The data you just input is wrong!";
return 0;
}
int main(void)
{
int months = 0;
int temp=0;
cout << "input month :" << endl;
cin >> temp;
while(temp > 12 || temp < 0)
{
cout << "input data error : month should between 1-12." << endl;
cout << "input month: " <<endl;
cin >> temp;
}
months = temp;
cout << " the months is :" << months << endl;
}