#include #include #include #include int main(){ char riadok[499][499]; int i, o , need = 0; bool first; while (1){ o = 0; while (1){ riadok[i][o] = getchar(); if (riadok[i][o] == '\n'){ first = true; need++; break; } o++; } if (first == true && riadok[i][0] == '\n'){ break; } i++; } for (int j = 0; j < need - 1; j++){ for (int g = 0; g < strlen(riadok[j]); g++){ if (riadok[j][g] != '.' && riadok[j][g] != '1' && riadok[j][g] != '2' && riadok[j][g] != '3' && riadok[j][g] != '4' && riadok[j][g] != '5' && riadok[j][g] != '6' && riadok[j][g] != '7' && riadok[j][g] != '8' && riadok[j][g] != '9' && riadok[j][g] != '0' && riadok[j][g] != '\n' && riadok[j][g] != '\0'){ riadok[j][0] = '9'; riadok[j][1] = '.'; riadok[j][2] = '9'; riadok[j][3] = '.'; riadok[j][4] = '9'; riadok[j][5] = '.'; riadok[j][6] = '\0'; break; } } } i = 0; for (int j = 0; j < need - 1; j++){ i = 1; for (int g = 0; g < strlen(riadok[j]); g++){ if ((riadok[j][g] == '1' && riadok[j][g] == '2' && riadok[j][g] == '3' && riadok[j][g] == '4' && riadok[j][g] == '5' && riadok[j][g] == '6' && riadok[j][g] == '7' && riadok[j][g] == '8' && riadok[j][g] == '9' && riadok[j][g] == '0' && riadok[j][g] == '\0')){ i++; if (strlen(riadok[j]) == i){ riadok[j][0] = '9'; riadok[j][1] = '.'; riadok[j][2] = '9'; riadok[j][3] = '.'; riadok[j][4] = '9'; riadok[j][5] = '.'; riadok[j][6] = '\0'; break; } } } } for (int j = 0; j < need - 1; j++){ if (riadok[j][0] == '0'){ riadok[j][0] = '9'; riadok[j][1] = '.'; riadok[j][2] = '9'; riadok[j][3] = '.'; riadok[j][4] = '9'; riadok[j][5] = '.'; riadok[j][6] = '\0'; } } for (int j = 0; j < need - 1; j++){ for (int g = 0; g < strlen(riadok[j]); g++){ if (riadok[j][g] == '0' && riadok[j][g - 1] == '.'){ riadok[j][0] = '9'; riadok[j][1] = '.'; riadok[j][2] = '9'; riadok[j][3] = '.'; riadok[j][4] = '9'; riadok[j][5] = '.'; riadok[j][6] = '\0'; } } } char riadok1[499]; i = 0; for (int j = 0; j < need - 1; j++){ for (int g = 0; g < strlen(riadok[j]); g++){ if (riadok[j][g] == '\n'){ riadok[j][g] = '.'; } if (riadok[j][g] != '\0'){ riadok1[i] = riadok[j][g]; i++; } } } riadok1[i] = '\0'; int len = strlen(riadok1); int s = 0; for (int j = 0; j < len; j++){ if (riadok1[j] == '.'){ s++; } } char *endptr = NULL; char *start = riadok1; int number[s]; i = 0; while (start < (riadok1 + len)){ number[i] = strtol(start, &endptr, 10); if (number[i]) start = endptr + 1; else break; i++; } need = 0; for (int j = 0; j < s; j = j + 3){ if (number[j + 1] > 12 && number[j + 1] < 0 && number[j] < 1 && number[j] > 31 && number[j + 2] < 1900 && number[j + 2] > 2100){ number[j] = 0; number[j + 1] = 0; number[j + 2] = 0; need++; } } for (int j = 0; j < s; j = j + 3){ if (number[j + 1] == 2 && number[j] == 29 && number[j + 2] % 4 != 0) { number[j] = 0; number[j + 1] = 0; number[j + 2] = 0; need++; } } for (int j = 0; j < s; j = j + 3){ if (number[j + 1] == 1 && number[j] > 0 && number[j] <= 31){ if (number[j] <= 24) number[j] = number[j] + 7; else if (number[j] > 24){ number[j] = number[j] + 7 - 31; number[j + 1]++; } } else if (number[j + 1] == 2 && number[j] > 0 && number[j] <= 28 && number[j + 2] % 4 != 0){ if (number[j] <= 21){ number[j] = number[j] + 7; } else if (number[j] > 21){ number[j] = number[j] + 7 - 28; number[j + 1]++; } } else if (number[j + 1] == 2 && number[j] > 0 && number[j] <= 29 && number[j + 2] % 4 == 0){ if (number[j] <= 22){ number[j] = number[j] + 7; } else if (number[j] > 22){ number[j] = number[j] + 7 - 29; number[j + 1]++; } } else if (number[j + 1] == 3 && number[j] > 0 && number[j] <= 31){ if (number[j] <= 24){ number[j] = number[j] + 7; } else if (number[j] > 24){ number[j] = number[j] + 7 - 31; number[j + 1]++; } } else if (number[j + 1] == 4 && number[j] > 0 && number[j] <= 30){ if (number[j] <= 23){ number[j] = number[j] + 7; } else if (number[j] > 23){ number[j] = number[j] + 7 - 30; number[j + 1]++; } } else if (number[j + 1] == 5 && number[j] > 0 && number[j] <= 31){ if (number[j] <= 24){ number[j] = number[j] + 7; } else if (number[j] > 24){ number[j] = number[j] + 7 - 31; number[j + 1]++; } } else if (number[j + 1] == 6 && number[j] > 0 && number[j] <= 30){ if (number[j] <= 23){ number[j] = number[j] + 7; } else if (number[j] > 23){ number[j] = number[j] + 7 - 30; number[j + 1]++; } } else if (number[j + 1] == 7 && number[j] > 0 && number[j] <= 31){ if (number[j] <= 24){ number[j] = number[j] + 7; } else if (number[j] > 24){ number[j] = number[j] + 7 - 31; number[j + 1]++; } } else if (number[j + 1] == 8 && number[j] > 0 && number[j] <= 31){ if (number[j] <= 24){ number[j] = number[j] + 7; } else if (number[j] > 24){ number[j] = number[j] + 7 - 31; number[j + 1]++; } } else if (number[j + 1] == 9 && number[j] > 0 && number[j] <= 30){ if (number[j] <= 23){ number[j] = number[j] + 7; } else if (number[j] > 23){ number[j] = number[j] + 7 - 30; number[j + 1]++; } } else if (number[j + 1] == 10 && number[j] > 0 && number[j] <= 31){ if (number[j] <= 24){ number[j] = number[j] + 7; } else if (number[j] > 24){ number[j] = number[j] + 7 - 31; number[j + 1]++; } } else if (number[j + 1] == 11 && number[j] > 0 && number[j] <= 30){ if (number[j] <= 23){ number[j] = number[j] + 7; } else if (number[j] > 23){ number[j] = number[j] + 7 - 30; number[j + 1]++; } } else if (number[j + 1] == 12 && number[j] > 0 && number[j] <= 31){ if (number[j] <= 24){ number[j] = number[j] + 7; } else if (number[j] > 24){ number[j] = number[j] + 7 - 31; number[j + 1] = 1; number[j + 2]++; } } if (number[j] != 0 && number[j + 1] != 0 && number[j + 2] != 0){ printf("%d.%d.%d\n\n", number[j], number[j + 1], number[j + 2]); } else if (number[j] == 0 && number[j + 1] == 0 && number[j + 2] == 0){ puts("Neplatny datum."); } } }