给出年月日,算出这是一年中的第几天

#include<iostream>
using namespace std;

int main()
{
    
int year,month,day;
    
int m[12]={31,2831,30,31,30,31,31,30,31,30,31};
    cout
<<"请输入年月日:";
    cin
>>year>>month>>day;
    
if(year%400==0 || year%4==0 && year%100!=0)
        m[
1]=29;
    
int sumdays=0;
    
for(int i=0;i<month-1;i++){
        sumdays
+=m[i];
    }

    sumdays
+=day;
    cout
<<year<<""<<month<<""<<day<<"日是一年中的第"<<sumdays<<""<<endl;
    system(
"pause");
    
return 0;
}

posted on 2011-06-08 21:52 Hsssssss 阅读(464) 评论(0)  编辑 收藏 引用 所属分类: C++代码


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


<2024年5月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

导航

统计

常用链接

留言簿

文章分类

文章档案

收藏夹

搜索

最新评论