302班

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

          #include<stdio.h>

          struct time
          {
            int hour;
            int minutes;
            int seconds;
          };

          int main(void)
          {
            struct time timeUpdate(struct time now);
            struct time currentTime,nextTime;

            printf("Enter the time (hh:mm:ss).\n");
            scanf("%i:%i:%i",&currentTime.hour,&currentTime.minutes,&currentTime.seconds);

            nextTime=timeUpdate(currentTime);
            printf("Updated time is %.2i:%.2i:%.2i\n",nextTime.hour,nextTime.minutes,nextTime.seconds);

            return 0;
          }

          struct time timeUpdate(struct time now)
          {
            ++now.seconds;
            if(now.seconds==60)
            {
              now.seconds=0;
           ++now.minutes;
           if(now.minutes==60)
           {
             now.minutes=0;
             ++now.hour;
             if(now.hour=24)
              now.hour=0;
           }
            }
            return now;
          }

          測試結(jié)果:

          主站蜘蛛池模板: 崇州市| 米易县| 潢川县| 中卫市| 陆良县| 木兰县| 桓仁| 长沙市| 蕉岭县| 卓尼县| 万荣县| 邹城市| 广昌县| 德保县| 桓台县| 建阳市| 武平县| 托克托县| 阜康市| 志丹县| 永新县| 凉城县| 石阡县| 天长市| 齐河县| 永昌县| 贵港市| 阿拉善左旗| 山阴县| 合山市| 哈密市| 颍上县| 林芝县| 汽车| 武夷山市| 博罗县| 宣恩县| 曲麻莱县| 恭城| 阿拉善右旗| 铁力市|