pvjc20/du3/program.c

44 lines
538 B
C
Raw Normal View History

2020-03-25 14:43:33 +00:00
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int main()
{
char *str;
str = (char*) malloc(12);
scanf("%s",str);
int day=0;
int m=0;
int y=0;
2020-03-26 10:25:16 +00:00
sscanf(str, "%d.%d.%d", &day, &m, &y);
2020-03-25 14:43:33 +00:00
if( (day<0 || day>=31)||(m<0 || m>12)){
return 0;
}
day+=7;
if(day>31 && m%2!=0){
day-=31;
m++;
}
else if(day>30 && m%2==0){
if(m==2 &&(y%400==0 ||(y%100!=0 && y%4==0))){
day-=29;
}
else{
day-=31;
}
m++;
}
if(m>12){
m-=12;
y++;
}
2020-03-26 10:26:31 +00:00
printf(" %d.%d.%d\n",day,m,y);
2020-03-25 14:43:33 +00:00
return 0;
}