59 lines
1.3 KiB
C
59 lines
1.3 KiB
C
#include <stdio.h>
|
|
|
|
int main(){
|
|
int day;
|
|
int month;
|
|
int year;
|
|
scanf("%d.%d.%d", &day, &month, &year);
|
|
if(day < 1 || day > 31 || month < 1 || month > 12){
|
|
puts("Neplatny datum");
|
|
return 0;
|
|
}
|
|
if(month == 2 && day > 29){
|
|
puts("Neplatny datum");
|
|
return 0;
|
|
}
|
|
if(year % 4 != 0 && month == 2 && day > 28){
|
|
puts("Neplatny datum");
|
|
return 0;
|
|
}
|
|
if(month == 4 || month == 6 || month == 9 || month == 11 && day > 30){
|
|
puts("Neplatny datum");
|
|
return 0;
|
|
}
|
|
|
|
day += 7;
|
|
if(year % 4 != 0 && month == 2 && day > 28){
|
|
month++;
|
|
day -= 28;
|
|
}
|
|
else if(month == 2 && day > 29){
|
|
month++;
|
|
day -= 29;
|
|
}
|
|
else if(month == 4 && month == 6 && month == 9 && month == 11 && day > 30){
|
|
month++;
|
|
day -= 30;
|
|
}
|
|
else if(day > 31){
|
|
month++;
|
|
day -= 31;
|
|
}
|
|
if(month == 13){
|
|
month = 1;
|
|
year++;
|
|
}
|
|
|
|
if(month < 10 && day < 10){
|
|
printf("_%d.0%d.%d\n", day, month, year);
|
|
}
|
|
else if(month < 10){
|
|
printf("%d.0%d.%d\n", day, month, year);
|
|
}
|
|
else if(day < 10){
|
|
printf("_%d.%d.%d\n", day, month, year);
|
|
}
|
|
else{
|
|
printf("%d.%d.%d\n", day, month, year);
|
|
}
|
|
} |