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é)果:

          主站蜘蛛池模板: 永和县| 大理市| 兰坪| 西和县| 甘谷县| 西宁市| 余姚市| 阿拉尔市| 建水县| 新化县| 娱乐| 集贤县| 南康市| 霍城县| 泰来县| 紫金县| 桐梓县| 鄂伦春自治旗| 波密县| 安多县| 手游| 基隆市| 海宁市| 浦江县| 木兰县| 张掖市| 富顺县| 咸宁市| 沧州市| 汽车| 当雄县| 深圳市| 永嘉县| 青河县| 太康县| 松桃| 安塞县| 鄂托克旗| 湄潭县| 乾安县| 东安县|