定义一个日期类Date,内有数据成员年、月、日,另有成员函数:构造函数用于初始化数据成员,输出,闰年的判断。 编写主函数:创建日期对象,计算并输出该日是该年的第几天。 输入格式: 测试输入包含若干测试用例,每个测试用例占一行。当读入0 0 0时输入结束,相应的结果不要输出。

输入样例:

2006 3 5
2000 3 5
0 0 0
输出样例:(括号内为说明)

64 (2006年3月5日是该年的第64天)
65 (2000年3月5日是该年的第65天)

#include<iostream>
using namespace std;
int A[12]={31,29,31,30,31,30,31,31,30,31,30,31};
int B[12]={31,28,31,30,31,30,31,31,30,31,30,31};
class Date
{
	int year;
	int month;
	int day;
	public:
		Date(int y,int m,int d):year(y),month(m),day(d){;}
		void show()
		{
			if((year%4==0&&year%100!=0)||year%400==0)
			{
				for(int i=0;i<month-1;i++)
				{
					day+=A[i];
				}
			}
			else
			{
				for(int i=0;i<month-1;i++)
				{
					day+=B[i];
				}
			}
			cout<<day<<endl;
		}
};
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	while(a!=0&&b!=0&&c!=0)
	{
		Date d(a,b,c);
		d.show();
		cin>>a>>b>>c;
	}
}