<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 :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    #include <stdio.h>

    struct time
    {
      int hour;
      int minute;
      int second;
    };
    struct date
    {
       int year;
       int month;
       int day;
    };
    struct dateAndTime
    {
       struct date sdate;
       struct time stime;
    };
    struct dateAndTime clockKeeper(struct dateAndTime s)
    {
     struct dateAndTime nextTime;
        struct time timeUpdate(struct time now);
     struct date dateUpdate(struct date today);
     int i=s.stime.hour;
        nextTime.stime=timeUpdate(s.stime);
     nextTime.sdate=s.sdate;
     if(i!=0&&(s.stime.hour==0))
     {
       nextTime.sdate=dateUpdate(s.sdate);
     }
     
     return nextTime;  
    }
    //日期更新
    struct date dateUpdate(struct date today)

      int numberOfDays(struct date d);
      struct date tomorrow;
      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=1;
      tomorrow.year=today.year+1;
      }
      else
      {
         tomorrow.day=1;
      tomorrow.month=today.month+1;
      tomorrow.year=today.year;
      }
      return tomorrow;
    }
      //查找一個月日期數的函數
      int numberOfDays(struct date d)
      {
         int days;
      int 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;
      }
      //判定是不是瑞年
      int isLeapYear(struct date d)
      {
         int leapYearFlag;
      if((d.year%4==0&&d.year%100!=0)||d.year%400==0)
      {
            leapYearFlag=1;
      }
      else
       leapYearFlag=0;
      return leapYearFlag;
      }
    //時間更新
      struct time timeUpdate(struct time now)
      {
        ++now.second;
     if(now.second==60)
     {
        now.second=0;
        ++now.minute;
        if(now.minute==60)
        {
       now.minute=0;
          ++now.hour;
       if(now.hour==24)
       {
         now.hour=0;
       }
        }  
     }
     return now;
      }
    int main(void)
    {
     struct dateAndTime s1={{2006,05,9},{23,59,59}};
     struct date today={2006,2,28};
     struct date tomorrow=dateUpdate(today);
     printf("%i%i%i\n",tomorrow.year,tomorrow.month,tomorrow.day);
     struct dateAndTime clockKeeper(struct dateAndTime s);
     
     struct dateAndTime upToNow=clockKeeper(s1);
     printf("The pre dateAndTime is %.4i/%.2i/%.2i  %.2i:%.2i:%.2i.\n",s1.sdate.year,s1.sdate.month,s1.sdate.day,s1.stime.hour,s1.stime.minute,s1.stime.second);
     printf("The pre dateAndTime is %.4i/%.2i/%.2i  %.2i:%.2i:%.2i.\n",upToNow.sdate.year,upToNow.sdate.month,upToNow.sdate.day,upToNow.stime.hour,upToNow.stime.minute,upToNow.stime.second);
        return 0;
    }
    測試結果:

    另一個測試:

    不過這里還存在一定的問題,就是日期不能更新,怪。還沒發現問題是什么

    主站蜘蛛池模板: 亚洲卡一卡2卡三卡4麻豆| 亚洲欧洲日产国码无码久久99| 亚洲最大福利视频网站| 免费萌白酱国产一区二区三区| 国产成人99久久亚洲综合精品| 人妻免费久久久久久久了| 亚洲成AV人在线观看网址| 成人免费网站久久久| 在线观看亚洲天天一三视| 中国国产高清免费av片| 久久久久久亚洲精品| 18禁美女黄网站色大片免费观看| 亚洲福利秒拍一区二区| 成年在线观看网站免费| 亚洲精品乱码久久久久蜜桃| 亚洲精品国产V片在线观看| 免费观看一区二区三区| 亚洲性色成人av天堂| 青青草国产免费久久久下载| 欧洲美女大片免费播放器视频 | 最近的中文字幕大全免费版| 亚洲av无码片在线观看| 国产一区视频在线免费观看| 一区二区三区免费看| 亚洲国产女人aaa毛片在线| 噼里啪啦电影在线观看免费高清| 亚洲男同gay片| 亚洲人成色777777在线观看| 91精品国产免费久久久久久青草| 国产精品亚洲精品日韩动图| 国产亚洲婷婷香蕉久久精品 | 亚洲综合图色40p| 99re在线精品视频免费| 亚洲天然素人无码专区| 亚洲永久精品ww47| 亚洲欧洲免费无码| 久久毛片免费看一区二区三区| 亚洲精品亚洲人成在线观看麻豆| 又粗又大又长又爽免费视频| 一级毛片成人免费看免费不卡| 亚洲AV一区二区三区四区|