302班

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

          #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;
          }
          運(yùn)行結(jié)果:

          主站蜘蛛池模板: 石家庄市| 仁寿县| 涟源市| 集贤县| 井陉县| 武穴市| 吉木萨尔县| 安新县| 琼海市| 玉龙| 吉林省| 晋宁县| 永平县| 营口市| 天门市| 西平县| 广饶县| 彭泽县| 莱芜市| 凤阳县| 平谷区| 澳门| 潜江市| 秦皇岛市| 博客| 从江县| 六安市| 永寿县| 金溪县| 石泉县| 乌拉特中旗| 中超| 丰县| 林芝县| 辛集市| 即墨市| 古田县| 高州市| 会同县| 丽江市| 乐都县|