主题:c++while循环语句
void CRecord::InputIncomeRecord()//增加收入数据 { int year,month,day; double income; char purpose[20]; cout<<"请输入日期:(例如:2012 2 29)"; cin>>year>>month>>day; while(!IsDateRight(year,month,day)) { cout<<"日期不正确!请重新输入:(例如:2012 2 29)"; cin>>year>>month>>day; } cout<<"请输入收入金额:"; cin>>income; cout<<"请输入来源:"; cin>>purpose; CFinance*pfinance=new CFinance; pfinance->SetFinance(year,month,day,income,0,purpose); CNode*pnode=new CNode; pnode->InputData(pfinance); list.Insert(pnode); cout<<"添加成功!"<<endl; list.CalBalance();}
bool IsDateRight(int year,int month,int day)//判断日期是否正确的函数 { if(year<999||year>3000)return false; if(month<0||month>12)return false; int DaysInMonth; switch(month) { case1: case3: case5: case7: case8: case10: case12:DaysInMonth=31;break; case4: case6: case9: case11:DaysInMonth=30;break; case2: { if(year%4==0&&year%400!=0)DaysInMonth=29; else DaysInMonth=28; break; } } if(day<0||day>DaysInMonth)return false; return true; }请问哪里出错了,不管输入什么都是提示我输入日期不正确并让我重新输入