Chinaunix首页 | 论坛 | 博客
  • 博客访问: 157668
  • 博文数量: 76
  • 博客积分: 1513
  • 博客等级: 上尉
  • 技术积分: 755
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-25 15:15
文章分类

全部博文(76)

文章存档

2012年(2)

2011年(74)

我的朋友

分类: C/C++

2011-11-25 21:14:58

  1. #include<iostream>

  2. using namespace std;

  3.  

  4. int main()

  5. {

  6.     int mb[12] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};

  7.     int input,year,month,day;

  8.     cout<<"input the yyyyddd format of date:"<<endl;

  9.     cin>>input;

  10.     year=input/1000;

  11.     if((year%4==0)&&((year%100!=0)||(year%400==0)))

  12.     //mb[12] = {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335};

  13.    {

  14.     cout<<"leap year"<<endl;

  15.     for(int i=2;i<12;i++)

  16.     mb[i]+=1;

  17.     }

  18.     input-=year*1000;

  19.     

  20.     cout<<"year:"<<year<<endl;

  21.     for(int i=0;i<12;i++)

  22.     {

  23.             if(mb[i]>=input)

  24.             {

  25.                    month=i;

  26.                    break;

  27.             }

  28.     }

  29.      cout<<"month:"<<month<<endl;

  30.     day=input-mb[month-1];

  31.     cout<<"day:"<<day<<endl;

  32.     return 0;

  33. }
阅读(1516) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~