56 lines
828 B
C
56 lines
828 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
int main()
|
|
{
|
|
char *str;
|
|
str = (char*) malloc(12);
|
|
scanf("%s",str);
|
|
int day=0;
|
|
int m=0;
|
|
int y=0;
|
|
sscanf(str, "%d.%d.%d", &day, &m, &y);
|
|
if(day>29 && m==2 &&(y%400!=0 ||(y%100==0 && y%4!=0))){
|
|
printf("Nespravny datum");
|
|
return 0;
|
|
}
|
|
day+=7;
|
|
if(m%2!=0 && day>31){
|
|
day-=31;
|
|
m++;
|
|
}
|
|
if(m%2==0 && day>30){
|
|
if(m==2 &&(y%400==0 ||(y%100!=0 && y%4==0))){
|
|
day-=29;
|
|
}
|
|
else if(m==2){
|
|
day-=28;
|
|
}
|
|
else{
|
|
day-=30;
|
|
}
|
|
m++;
|
|
}
|
|
if(m>12){
|
|
m-=12;
|
|
day--;
|
|
y++;
|
|
}
|
|
if(m>9 && day>9){
|
|
printf("%d.%d.%d\n",day,m,y);
|
|
}
|
|
else if(m<10 && day>9){
|
|
printf("%d.0%d.%d\n",day,m,y);
|
|
}
|
|
else if(m>9 && day<10){
|
|
printf(" %d.%d.%d\n",day,m,y);
|
|
}
|
|
else{
|
|
printf(" %d.0%d.%d\n",day,m,y);
|
|
}
|
|
printf("\n");
|
|
|
|
return 0;
|
|
}
|
|
|