From 1db858f56dd12d23adc1b17acd0cc7a685b8e8d3 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 26 Mar 2020 10:41:57 +0000 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20'du3/program.c'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du3/program.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/du3/program.c b/du3/program.c index 483f223..c0ce4c9 100644 --- a/du3/program.c +++ b/du3/program.c @@ -1,10 +1,11 @@ -#include #include +#include #include int main() { - - + + + char *str; str = (char*) malloc(12); scanf("%s",str); @@ -12,21 +13,17 @@ int day=0; int m=0; int y=0; sscanf(str, "%d.%d.%d", &day, &m, &y); -if( (day<0 || day>=31)||(m<0 || m>12)){ - return 0; -} - day+=7; -if(day>31 && m%2!=0){ +if(m%2!=0 && day>31){ day-=31; m++; } -else if(day>30 && m%2==0){ +if(m%2==0 && day>30){ if(m==2 &&(y%400==0 ||(y%100!=0 && y%4==0))){ day-=29; } else{ - day-=31; + day-=30; } m++; } @@ -34,10 +31,13 @@ if(m>12){ m-=12; y++; } - -printf(" %d.%d.%d\n",day,m,y); - - - return 0; +if(m>9){ + printf(" %d.%d.%d\n",day,m,y); +} +else{ + printf(" %d.0%d.%d\n",day,m,y); +} + + return 0; }