<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    302班

    java突擊隊
    posts - 151, comments - 74, trackbacks - 0, articles - 14
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    日期(today tomorrow)利用struct

    Posted on 2007-07-02 16:19 停留的風 閱讀(346) 評論(0)  編輯  收藏 所屬分類: C語言學習歷程

    #include <stdio.h>

    struct date
     {
       int month;
       int day;
       int year;
     };
    int main(void)
    {
        struct date today,tomorrow; 
        int numberOfDays(struct date d);

     printf("Enter today's date(mm dd yyyy):\n");
     scanf("%i %i %i",&today.month,&today.day,&today.year);
       
     if(today.day!=numberOfDays(today))
     {
       tomorrow.day=today.day+1;
       tomorrow.month=today.month;
       tomorrow.year=today.year;
        }
     else if(today.month!=12)
     {
       tomorrow.day=1;
       tomorrow.month=today.month+1;
       tomorrow.year=today.year;
     }
     else
     {
       tomorrow.day=1;
       tomorrow.month=1;
       tomorrow.year=today.year+1;
     }

     printf("Tomorrow's date is %i  %i  %.2i.\n",tomorrow.month,tomorrow.day,tomorrow.year%100);
     return 0;
     
    }

    int numberOfDays(struct date d)
    {
      int days;
      bool isLeapYear(struct date d);
      const int daysPerMonth[12]={31,28,31,30,31,30,31,31,30,31,30,31};
     
      if(isLeapYear(d)==1&&d.month==2)
      {
        days=29;
      }
      else
       days=daysPerMonth[d.month-1];
      return days;
    }

    bool isLeapYear(struct date d)
    {
      bool leapYearFlag;
      if((d.year%4==0&&d.year%100!=0)||d.year%400==0)
      {
        leapYearFlag=1;
      }
      else
     leapYearFlag=0;
      return leapYearFlag;
    }
    運行結果:

    主站蜘蛛池模板: 国产高清在线精品免费软件| 波多野结衣在线免费观看| 日韩高清免费在线观看| 在线aⅴ亚洲中文字幕| 日韩欧毛片免费视频| 33333在线亚洲| 成年人视频在线观看免费| 最新国产成人亚洲精品影院| 人妻视频一区二区三区免费| 国产亚洲精品bv在线观看| 日本免费网站观看| av成人免费电影| 国产AV无码专区亚洲精品| 国产91色综合久久免费| 亚洲精品无码不卡在线播放| 国产成人免费手机在线观看视频| 黄页网站在线观看免费| 亚洲精品无码成人AAA片| 一区二区三区观看免费中文视频在线播放| 久久精品国产亚洲av高清漫画| 午夜免费1000部| 亚洲国产精品网站在线播放| 亚洲国产午夜福利在线播放| 91在线免费视频| 亚洲日本香蕉视频| 国产伦一区二区三区免费 | 99久久久国产精品免费牛牛| 亚洲永久中文字幕在线| 日韩免费观看的一级毛片| 国产精品高清免费网站| 亚洲欧洲日产韩国在线| 最新69国产成人精品免费视频动漫| 四虎影视永久在线精品免费| 亚洲AV无码久久精品蜜桃| 大学生a级毛片免费观看| 不卡视频免费在线观看| 精品亚洲AV无码一区二区三区| 婷婷亚洲天堂影院| 成人浮力影院免费看| jzzjzz免费观看大片免费| 亚洲国产精品yw在线观看|