pvjc22/du4/program.c

52 lines
997 B
C
Raw Normal View History

2022-03-27 17:13:52 +00:00
nclude<stdio.h>
2022-03-27 10:13:22 +00:00
#include<string.h>
2022-03-27 17:13:52 +00:00
#include<time.h>
2022-03-27 10:13:22 +00:00
#include<stdlib.h>
2022-03-27 13:12:07 +00:00
2022-03-27 17:13:52 +00:00
int main(){
char Dnes_Datum[30];
int ch=getchar(),counter=0;
for(int idx=0;ch!=EOF;idx++){
if(ch=='.'){
ch=' ';
}
Dnes_Datum[idx]=ch;
if(ch=='\n'){
counter++;
}
2022-03-27 10:13:22 +00:00
ch=getchar();
2022-03-27 17:13:52 +00:00
if(Dnes_Datum[idx]=='\n'&&ch=='\n'){
break;
}
2022-03-27 10:13:22 +00:00
}
2022-03-27 13:19:33 +00:00
2022-03-27 17:13:52 +00:00
char *start=Dnes_Datum, *end=NULL;
time_t t=time(NULL);
2022-03-27 13:19:33 +00:00
2022-03-27 17:13:52 +00:00
for(int idx=0;idx<counter;idx++){
struct tm *D_D;
struct tm *NW_D;
2022-03-27 14:19:02 +00:00
2022-03-27 17:13:52 +00:00
D_D = localtime(&t);
2022-03-27 10:13:22 +00:00
2022-03-27 17:13:52 +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;
2022-03-27 12:47:33 +00:00
2022-03-27 17:13:52 +00:00
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);
2022-03-27 10:13:22 +00:00
}
2022-03-27 17:13:52 +00:00
return EXIT_SUCCESS;
2022-03-27 10:13:22 +00:00
}
2022-03-27 17:13:52 +00:00