From 5e2dc0a00bef41ec72e01b80810105ec034a720b Mon Sep 17 00:00:00 2001 From: Andrii Hermaniuk Date: Sun, 27 Mar 2022 18:57:22 +0200 Subject: [PATCH] aaa --- a1/program.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/a1/program.c b/a1/program.c index 2efa513..8183378 100644 --- a/a1/program.c +++ b/a1/program.c @@ -1,7 +1,41 @@ #include +#include +#include +#include + int main(){ -// printf("HELLO"); + char Dnes_Datum[30]; + struct tm *D_D; + struct tm *NW_D; + //fgets(Dnes_Datum,30,stdin); + //int Day=0,Mon=0,Year=0; + //scanf("%d %d %d",&Day,&Mon,&Year); + int ch=getchar(); + for(int idx=0;ch!='\n';idx++){ + if(ch=='.'){ + ch=' '; + } + Dnes_Datum[idx]=ch; + ch=getchar(); + } - return 0; + char *start=Dnes_Datum, *end=NULL; + time_t t=time(NULL); + D_D = localtime(&t); + + D_D->tm_mday=strtol(start,&end,10); + start=end; + D_D->tm_mon=strtol(start,&end,10)-1; + start=end; + D_D->tm_year=strtol(start,&end,10)-1900; + + time_t nex_week=mktime(D_D)+604800; + + NW_D=localtime(&nex_week); + + printf("%d.%d.%d\n",NW_D->tm_mday, NW_D->tm_mon+1,NW_D->tm_year+1900); + return EXIT_SUCCESS; } + +