Advertisement
FuFsQ

B2_A

Sep 26th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3.  
  4. using namespace std;
  5. #define sz(x) (sizeof(x)/sizeof(x[0]))
  6. #define np(i) (Date[i]-Baseof)
  7. #define sum(d,m,y) (d+m*31+y*365)
  8. int main()
  9. {
  10.     int allc = 21;
  11.     char Name[allc];
  12.     char Surname[allc];
  13.     char Date[12];
  14.  
  15.     char MName[allc];    // Имя и фамилия самого старшего человекав списке
  16.     char MSurname[allc];
  17.  
  18.     uint32_t Days_   = 60; // Дата рождения самого старшего чел. в списке
  19.     uint32_t Months_ = 60;
  20.     uint32_t Years_  = 5000;
  21.  
  22.     for(int i = 0; i < 21; i++)
  23.         Name[i] = ' ', Surname[i] = ' ';
  24.  
  25.     int N = 0;
  26.     scanf("%i",&N);
  27.  
  28.     if(N == 0){
  29.         printf("0");
  30.         return 0;
  31.     }
  32.  
  33.     int Baseof = int('0'); // Штука для быстрого получения int из строки
  34.  
  35.     int CNT = 1;
  36.     int Years,Months,Days;
  37.     for(int i = 0; i < N; i++){
  38.         scanf("%s %s %s", &Name, &Surname, &Date);
  39.  
  40.         //  DD.MM.YYYY
  41.         //  0  3  6  9
  42.         Days   = np(0)*10   + np(1);
  43.         Months = np(3)*10   + np(4);
  44.         Years  = np(6)*1000 + np(7)*100 + np(8)*10 + np(9);
  45.  
  46.         // перевод в дни для быстрого сравнения. Если Человек старше (sum<), то...
  47.         if(sum(Days,Months,Years) < sum(Days_,Months_,Years_)){
  48.             CNT = 1;
  49.             Days_   = Days;
  50.             Months_ = Months;
  51.             Years_  = Years;
  52.  
  53.             for(int t = 0; t < allc; t++){
  54.                 MName[t]    = Name[t];
  55.                 MSurname[t] = Surname[t];
  56.             }
  57.         }else if(sum(Days,Months,Years) == sum(Days_,Months_,Years_)){
  58.             CNT++;
  59.         }
  60.  
  61.     }
  62.  
  63.     if(CNT == 1)
  64.         printf("%s %s %02d.%02d.%04d", MName, MSurname, Days_, Months_, Years_);
  65.     else
  66.         printf("%d", CNT);
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement