pvjc20/du3/program.c

46 lines
594 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-=28;
}
else if(m==2){
day-=30;
}
else{
day-=30;
}
m++;
}
if(m>12){
m-=12;
day--;
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;
}