pvjc22/a1/program.c

52 lines
1000 B
C
Raw Normal View History

2022-03-27 14:45:37 +00:00
#include<stdio.h>
2022-03-27 16:57:22 +00:00
#include<string.h>
#include<time.h>
#include<stdlib.h>
2022-03-27 14:45:37 +00:00
int main(){
2022-03-27 17:29:12 +00:00
char Dnes_Datum[300];
2022-03-27 17:18:45 +00:00
int ch=getchar(),counter=0;
for(int idx=0;ch!=EOF;idx++){
2022-03-27 16:57:22 +00:00
if(ch=='.'){
ch=' ';
}
Dnes_Datum[idx]=ch;
2022-03-27 17:18:45 +00:00
if(ch=='\n'){
counter++;
}
2022-03-27 16:57:22 +00:00
ch=getchar();
2022-03-27 17:18:45 +00:00
if(Dnes_Datum[idx]=='\n'&&ch=='\n'){
break;
}
2022-03-27 16:57:22 +00:00
}
char *start=Dnes_Datum, *end=NULL;
time_t t=time(NULL);
2022-03-27 17:18:45 +00:00
for(int idx=0;idx<counter;idx++){
struct tm *D_D;
struct tm *NW_D;
2022-03-27 16:57:22 +00:00
2022-03-27 17:18:45 +00:00
D_D = localtime(&t);
2022-03-27 14:45:37 +00:00
2022-03-27 17:18:45 +00:00
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;
start=end+1;
time_t nex_week=mktime(D_D)+604800;
NW_D=localtime(&nex_week);
printf("%d.%d.%d\n\n",NW_D->tm_mday, NW_D->tm_mon+1,NW_D->tm_year+1900);
}
return EXIT_SUCCESS;
2022-03-27 16:57:22 +00:00
2022-03-27 14:45:37 +00:00
}
2022-03-27 16:57:22 +00:00
2022-03-27 17:18:45 +00:00