Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdio.h>
- using namespace std;
- #define sz(x) (sizeof(x)/sizeof(x[0]))
- #define np(i) (Date[i]-Baseof)
- #define sum(d,m,y) (d+m*31+y*365)
- int main()
- {
- int allc = 21;
- char Name[allc];
- char Surname[allc];
- char Date[12];
- char MName[allc]; // Имя и фамилия самого старшего человекав списке
- char MSurname[allc];
- uint32_t Days_ = 60; // Дата рождения самого старшего чел. в списке
- uint32_t Months_ = 60;
- uint32_t Years_ = 5000;
- for(int i = 0; i < 21; i++)
- Name[i] = ' ', Surname[i] = ' ';
- int N = 0;
- scanf("%i",&N);
- if(N == 0){
- printf("0");
- return 0;
- }
- int Baseof = int('0'); // Штука для быстрого получения int из строки
- int CNT = 1;
- int Years,Months,Days;
- for(int i = 0; i < N; i++){
- scanf("%s %s %s", &Name, &Surname, &Date);
- // DD.MM.YYYY
- // 0 3 6 9
- Days = np(0)*10 + np(1);
- Months = np(3)*10 + np(4);
- Years = np(6)*1000 + np(7)*100 + np(8)*10 + np(9);
- // перевод в дни для быстрого сравнения. Если Человек старше (sum<), то...
- if(sum(Days,Months,Years) < sum(Days_,Months_,Years_)){
- CNT = 1;
- Days_ = Days;
- Months_ = Months;
- Years_ = Years;
- for(int t = 0; t < allc; t++){
- MName[t] = Name[t];
- MSurname[t] = Surname[t];
- }
- }else if(sum(Days,Months,Years) == sum(Days_,Months_,Years_)){
- CNT++;
- }
- }
- if(CNT == 1)
- printf("%s %s %02d.%02d.%04d", MName, MSurname, Days_, Months_, Years_);
- else
- printf("%d", CNT);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement