急求:C++判断日期格式是否有效的函数

来源:百度知道 编辑:UC知道 时间:2024/06/25 00:40:47
比如输入年,月,日
判断它是不是有效

明天给你发过去
--------------------------------------
bool panduan (int a,int b,int c)
{
if (b<=12&&c<=31)
{ if (a%1000==0&&a%400==0&&b=2&&c==29) return true;
else if ((b==1||b==3||b==5||b==7||b==8||b==10||b==12)&&c==31) return true;
else return false;
}
else return false;
}

/*在调用我这个函数的时候,应该这样调用:

bool d;
int x,y,z;
bool panduan (int,int,int);
cin>>x>>y>>z;
d=panduan (x,y,z);
if (d==true) cout<<"有效!\n";
else cout<<"无效!\n";

*/

//(别忘了加上:#include <iostream>)

其时就是闰年问题