302班

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

          #include<stdio.h>

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

          int main(void)
          {
            struct time timeUpdate(struct time now);
            struct time testTimes[5]={{11,59,59},{12,0,0},{1,29,59},{23,59,59},{19,12,27}};
            int i;

            for(i=0;i<5;i++)
            {
              printf("Time is %.2i:%.2i%.2i",testTimes[i].hour,testTimes[i].minutes,testTimes[i].seconds);

           testTimes[i]=timeUpdate(testTimes[i]);

           printf(".....one second later it's %.2i%.2i%.2i\n",
            testTimes[i].hour,testTimes[i].minutes,testTimes[i].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;
          }

          運(yùn)行結(jié)果:

          主站蜘蛛池模板: 安图县| 樟树市| 贡嘎县| 苏尼特右旗| 华宁县| 晋城| 聂荣县| 伊金霍洛旗| 小金县| 博客| 淳安县| 东源县| 城步| 拜泉县| 商水县| 安化县| 彭泽县| 丰顺县| 江永县| 新郑市| 德兴市| 肇州县| 富川| 翁源县| 云浮市| 凉城县| 馆陶县| 麻江县| 望城县| 中山市| 图木舒克市| 什邡市| 宝清县| 大余县| 噶尔县| 房山区| 顺昌县| 潢川县| 富源县| 海口市| 乳源|