Aktualizovat "program.c

This commit is contained in:
Kristián Ruják 2019-03-13 22:45:13 +00:00
parent aa40bc2677
commit d5b31d649a

View File

@ -1,4 +1,4 @@
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>
int main() int main()
@ -8,48 +8,37 @@ int main()
int d; int d;
int ko; int ko;
scanf("%d.%d.%d", &d, &m, &y); scanf("%d.%d.%d", &d, &m, &y);
if(ko = 0){
return 0;}
if(y>=0 && y<=9999) if(y>=0 && y<=9999)
{ {
if(ko = 0){ if(ko = 0){
return 0;} return 0;}
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
if(m>=1 && m<=12) if(m>=1 && m<=12)
{ {
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
if((d>=1 && d<=31) && (m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12)) if((d>=1 && d<=31) && (m==1 || m==3 || m==5 || m==7 || m==8 || m==10 || m==12))
{} {}
@ -59,7 +48,19 @@ int main()
else if((d>=1 && d<=30) && m==4 || m==6 || m==9 || m==11) else if((d>=1 && d<=30) && m==4 || m==6 || m==9 || m==11)
{} {}
@ -81,14 +82,12 @@ int main()
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
@ -98,15 +97,18 @@ int main()
} }
} }
if(ko = 0){
return 0;}
else else
{ {
printf("Nespravny datum\n"); printf("Nespravny datum\n");
@ -114,12 +116,16 @@ int main()
return 0; return 0;
} }
} if(ko = 0){ }
return 0;}
else else
{ {
printf("Nespravny datum\n"); printf("Nespravny datum\n");
@ -127,21 +133,24 @@ int main()
} }
struct tm t = { .tm_year=y-1900, .tm_mon=m-1, .tm_mday=d }; struct tm t = { .tm_year=y-1900, .tm_mon=m-1, .tm_mday=d };
t.tm_mday += 7; t.tm_mday += 7;
mktime(&t); mktime(&t);
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
@ -186,5 +195,4 @@ int main()
printf("%d.%d.%d\n\n", t.tm_mday, t.tm_mon+1, t.tm_year+1900); printf("%d.%d.%d\n\n", t.tm_mday, t.tm_mon+1, t.tm_year+1900);
} }
} }