From 3fa7c393fa9cb531517281b65e08c015a4d6e243 Mon Sep 17 00:00:00 2001 From: Pavlo Tverdyi Date: Thu, 26 Mar 2020 10:25:16 +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 | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/du3/program.c b/du3/program.c index 2f68391..2a4c748 100644 --- a/du3/program.c +++ b/du3/program.c @@ -11,16 +11,7 @@ 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; -} +sscanf(str, "%d.%d.%d", &day, &m, &y); if( (day<0 || day>=31)||(m<0 || m>12)){ return 0; } @@ -44,7 +35,7 @@ if(m>12){ y++; } -printf("%d.%d.%d",day,m,y); +printf(" %d.%d.%d",day,m,y); return 0;