計算日差


2つの日付の間に何日の差があるかを計算します.
しかし、私はそれが一人が生まれてから今日まで何日生きたかを計算するのに使えるとしか思えません.
非常に未熟なコードで、乱れているところもあります.
そして入力を判断するのに苦労しましたが、完璧ではありません.

  
  
  
  
  1. #include <iostream> 
  2. #include <conio.h>  
  3.   
  4. #define LEAPYEAR 366//   
  5. #define COMMONYEAR 365//   
  6. #define LEAPFEBRUARY 29//   
  7.   
  8. using namespace std;  
  9.   
  10. int main(int argc,char *argv[]) 
  11.     int brithYear,brithMonth,brithDay,signBrithYear=0; //   
  12.     int nowYear,nowMonth,nowDay,signNowYear=0; //   
  13.     long long allDayLive=0;//   
  14.     int tempYear,tempMonth; 
  15.     //   
  16.     int brithMonthDay[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};  
  17.     int nowMonthDay[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 
  18.       
  19.     // 2200 ,   
  20.     cout<<"*********************************************"<<endl; 
  21.     cout<<" ! !"<<endl; 
  22.     cout<<" ! 1 2200 !"<<endl;   
  23.     cout<<"*********************************************
    "
    <<endl; 
  24.       
  25.     //     
  26.     cout<<" , :yyyy mm dd"<<endl; 
  27.     cin>>brithYear>>brithMonth>>brithDay; 
  28.     cout<<"
    , :yyyy mm dd"
    <<endl; 
  29.     cin>>nowYear>>nowMonth>>nowDay;  
  30.       
  31.     // ,   
  32.     if(brithYear%100!=0&&brithYear%4==0||brithYear%400==0)  
  33.     { 
  34.         signBrithYear=1; 
  35.         brithMonthDay[2]=LEAPFEBRUARY; 
  36.     } 
  37.     if(nowYear%100!=0&&nowYear%4==0||nowYear%400==0)  
  38.     { 
  39.         signNowYear=1; 
  40.         nowMonthDay[2]=LEAPFEBRUARY; 
  41.     } 
  42.       
  43.     //   
  44.     if
  45.         brithYear<=0|| 
  46.         brithMonth<=0|| 
  47.         brithDay<=0|| 
  48.         nowYear<=0|| 
  49.         nowMonth<=0|| 
  50.         nowDay<=0|| 
  51.         brithYear>9999||//   
  52.         nowYear>9999|| 
  53.         brithMonth>12|| 
  54.         nowMonth>12|| 
  55.         brithYear>nowYear 
  56.     ) 
  57.     { 
  58.         cout<<"
    ! (Enter) 。"
    <<endl; 
  59.         getch(); 
  60.         return -1; 
  61.     }  
  62.     if(brithYear==nowYear) 
  63.     { 
  64.         if(brithMonth>nowMonth) 
  65.         { 
  66.             cout<<"
    ! (Enter) 。"
    <<endl; 
  67.             getch(); 
  68.             return -1; 
  69.         } 
  70.     } 
  71.     if(brithYear==nowYear) 
  72.     { 
  73.         if(brithMonth==nowMonth) 
  74.         { 
  75.             if(brithDay>nowDay) 
  76.             { 
  77.                 cout<<"
    ! (Enter) 。"
    <<endl; 
  78.                 getch(); 
  79.                 return -1; 
  80.             } 
  81.         } 
  82.     } 
  83.     if(brithDay>brithMonthDay[brithMonth]||nowDay>nowMonthDay[nowMonth]) 
  84.     { 
  85.         cout<<"
    ! (Enter) 。"
    <<endl; 
  86.         getch(); 
  87.         return -1;   
  88.     } 
  89.       
  90.     // ,   
  91.     //   
  92.     if(brithYear!=nowYear) 
  93.     {  
  94.         //  
  95.         for(tempYear=brithYear+1;tempYear<nowYear;tempYear++) 
  96.         { 
  97.             if(tempYear%100!=0&&tempYear%4==0||tempYear%400==0) 
  98.             { 
  99.                 allDayLive+=LEAPYEAR; 
  100.             } 
  101.             else 
  102.             { 
  103.                 allDayLive+=COMMONYEAR; 
  104.             } 
  105.         }  
  106.       
  107.         //   
  108.         if(brithMonth==1) 
  109.         { 
  110.             if(signBrithYear==1) 
  111.             { 
  112.                 allDayLive+=LEAPFEBRUARY; 
  113.             } 
  114.         } 
  115.         for(tempMonth=brithMonth+1;tempMonth<=12;tempMonth++) 
  116.         { 
  117.             allDayLive+=brithMonthDay[tempMonth]; 
  118.         } 
  119.         if(brithMonth==2) 
  120.         { 
  121.             if(signBrithYear==1) 
  122.             { 
  123.                 allDayLive+=(LEAPFEBRUARY-brithDay); 
  124.             } 
  125.         } 
  126.         else 
  127.         { 
  128.             allDayLive+=(brithMonthDay[brithMonth]-brithDay); 
  129.         } 
  130.       
  131.         //  
  132.         for(tempMonth=1;tempMonth<nowMonth;tempMonth++) 
  133.         { 
  134.             allDayLive+=nowMonthDay[tempMonth]; 
  135.         } 
  136.         allDayLive+=nowDay; 
  137.     } 
  138.     //   
  139.     else 
  140.     { 
  141.         if(brithMonth==nowMonth) 
  142.         { 
  143.             allDayLive+=nowDay-brithDay; 
  144.         } 
  145.         else 
  146.         { 
  147.             for(tempMonth=brithMonth+1;tempMonth<nowMonth;tempMonth++) 
  148.             { 
  149.                 allDayLive+=brithMonthDay[tempMonth]; 
  150.             } 
  151.             allDayLive+=brithMonthDay[brithMonth]-brithDay; 
  152.             allDayLive+=nowDay; 
  153.         } 
  154.     } 
  155.       
  156.     //  
  157.     cout<<"
     "
    <<allDayLive<<"  。"<<endl; 
  158.     cout<<"
    (Enter) 。"
    <<endl;  
  159.       
  160.     getch(); 
  161.       
  162.     return 0;