pvjc20/du3/program.c

45 lines
546 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);
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{
day-=30;
}
m++;
}
if(m>12){
m-=12;
y++;
}
if(m>9){
printf(" %d.%d.%d\n",day,m,y);
}
else{
printf(" %d.0%d.%d\n",day,m,y);
}
printf("\n");
return 0;
}