その年の何日目

880 ワード

/*
*            :
*Copyright(c)2013,           
*All rights reserved.
*    :
*  :   
*    :2013  11 21  
*   :v1.0
*             :
*    :
*    :              
*    :
*    :
*    :
*/

#include<iostream>
using namespace std;
int time(int,int,int);
int main()
{
	int year,month,day,tian;
	cout<<"      :"<<endl;
	cin>>year>>month>>day;
	tian=time(year,month,day);
	cout<<year<<" "<<month<<" "<<day<<"      "<<tian<<" "<<endl;
	return 0;
}
int time(int y,int m,int d)
{
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},i,tian;
	//    13     ,    
	tian=d;//         ,        0,tian      d...
	for(i=1;i<m;i++)
	{
		tian+=a[i];
	}
	if(m>2&&(y%4==0&&y%100!=0||y%4==0))
		tian++;
	return tian;
}