pvjc20/du3/program.c

64 lines
1.3 KiB
C
Raw Normal View History

2020-03-26 22:06:43 +00:00
#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){
2020-03-26 23:01:20 +00:00
puts("Nespravny datum");
2020-03-26 22:06:43 +00:00
return 0;
}
if(month == 2 && day > 29){
2020-03-26 23:01:20 +00:00
puts("Nespravny datum");
2020-03-26 22:06:43 +00:00
return 0;
}
if(year % 4 != 0 && month == 2 && day > 28){
2020-03-26 23:01:20 +00:00
puts("Nespravny datum");
2020-03-26 22:06:43 +00:00
return 0;
}
2020-03-26 22:58:22 +00:00
if(month == 4 || month == 6 || month == 9 || month == 11){
if(day > 30){
2020-03-26 23:01:20 +00:00
puts("Nespravny datum");
2020-03-26 22:06:43 +00:00
return 0;
2020-03-26 22:58:22 +00:00
}
2020-03-26 22:06:43 +00:00
}
day += 7;
if(year % 4 != 0 && month == 2 && day > 28){
month++;
day -= 28;
}
else if(month == 2 && day > 29){
month++;
day -= 29;
}
2020-03-26 22:58:22 +00:00
else if(month == 4 || month == 6 || month == 9 || month == 11){
if(day > 30){
2020-03-26 22:06:43 +00:00
month++;
day -= 30;
2020-03-26 22:58:22 +00:00
}
2020-03-26 22:06:43 +00:00
}
else if(day > 31){
month++;
day -= 31;
}
if(month == 13){
month = 1;
year++;
}
2020-03-26 22:37:39 +00:00
if(month < 10 && day < 10){
2020-03-26 22:51:35 +00:00
printf(" %d.0%d.%d\n\n", day, month, year);
2020-03-26 22:37:39 +00:00
}
2020-03-26 22:06:43 +00:00
else if(month < 10){
2020-03-26 22:46:29 +00:00
printf("%d.0%d.%d\n\n", day, month, year);
2020-03-26 22:06:43 +00:00
}
2020-03-26 22:37:39 +00:00
else if(day < 10){
2020-03-26 22:51:35 +00:00
printf(" %d.%d.%d\n\n", day, month, year);
2020-03-26 22:37:39 +00:00
}
2020-03-26 22:06:43 +00:00
else{
2020-03-26 22:46:29 +00:00
printf("%d.%d.%d\n\n", day, month, year);
2020-03-26 22:06:43 +00:00
}
2020-03-26 22:58:22 +00:00
}