From 1c011fddb71a218456fa099c59a5811a673b039e Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Wed, 25 Mar 2020 14:43:33 +0000 Subject: [PATCH] =?UTF-8?q?P=C5=99idat=20=E2=80=9Edu3/program.c=E2=80=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du3/program.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 du3/program.c diff --git a/du3/program.c b/du3/program.c new file mode 100644 index 0000000..2f68391 --- /dev/null +++ b/du3/program.c @@ -0,0 +1,52 @@ +#include +#include +#include +int main() +{ + + +char *str; +str = (char*) malloc(12); +scanf("%s",str); +int day=0; +int m=0; +int y=0; +if(str[1]=='.'){ + day+=str[0]-48; + m+=(str[2]-48)*10+(str[3]-48); + y+=(str[5]-48)*1000+(str[6]-48)*100+(str[7]-48)*10+str[8]-48; +} +else{ + day+=(str[0]-48)*10+(str[1]-48); + m+=(str[3]-48)*10+(str[4]-48); + y+=(str[6]-48)*1000+(str[7]-48)*100+(str[8]-48)*10+str[9]-48; +} +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++; +} + +printf("%d.%d.%d",day,m,y); + + + return 0; +} +