/*
*Copyright(c)2014,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:曾晓
*完成日期:2014年 12月 22日
*版本号:v1.0
*/
#include <iostream>
using namespace std;
struct Date
{
int year;
int month;
int day;
int hour;
int minute;
int second;
};
int main( )
{
Date date;
int days=0,i;
cout<<"请输入年月日时分秒:"<<endl;
cin>>date.year>>date.month>>date.day>>date.hour>>date.minute>>date.second;
int day[13]= {31,28,31,30,31,30,31,31,30,31,30,31};
if((date.year%4==0&&date.year%100!=0)||(date.year%400==0))
day[2]++;
for(i=0; i<date.month; i++)
days+=day[i];
days+=date.day;
cout<<date.year<<"年"<<date.month<<"月"<<date.day<<"日,是该年的第"<<days<<"天"<<endl;
int Second;
Second=date.hour*3600+date.minute*60+date.second;
cout<<date.hour<<"时"<<date.minute<<"分"<<date.second<<"秒是该天的第"<<Second<<"秒"<<endl;
return 0;
}
运行结果: