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,42 +8,33 @@ 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){
return 0;}
if(ko = 0){
return 0;}
if(ko = 0){ if(ko = 0){
return 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))
{} {}
@ -54,8 +45,6 @@ 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)
{} {}
@ -66,6 +55,18 @@ int main()
else if((d>=1 && d<=28) && m==2) else if((d>=1 && d<=28) && m==2)
{} {}
@ -81,14 +82,12 @@ int main()
if(ko = 0){
return 0;}
if(ko = 0){
return 0;}
@ -98,8 +97,7 @@ int main()
} }
} }
if(ko = 0){
return 0;}
@ -112,36 +110,47 @@ int main()
return 0; return 0;
} }
} if(ko = 0){ }
return 0;}
else else
{ {
printf("Nespravny datum\n"); printf("Nespravny datum\n");
return 0; return 0;
} }
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;}
@ -187,4 +196,3 @@ int main()
} }
} }