-
Notifications
You must be signed in to change notification settings - Fork 0
/
datecom.c
77 lines (73 loc) · 1.54 KB
/
datecom.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
typedef struct date{
int year;
int month;
int dat;
}datee;
typedef struct time{
int sec;
int min;
int hour;
}timee;
void display(datee dd){
printf("the date is %d / %d / %d \n ",dd.dat,dd.month,dd.year);
}
void display1(timee dk){
printf("the time is %d / %d / %d \n ",dk.sec,dk.min,dk.hour);
}
int datetime(datee df, datee hf, timee tf , timee lf){
if(df.year>hf.year || tf.hour < lf.hour){
return 1;
}
if(df.year>hf.year || tf.hour > lf.hour){
return 1;
}
if(df.year<hf.year || tf.hour < lf.hour){
return -1;
}
if(df.year<hf.year || tf.hour > lf.hour){
return 1;
}
if(df.month>hf.month || tf.min > lf.min){
return -1;
}
if(df.month>hf.month || tf.min < lf.min){
return 1;
}
if(df.month<hf.month || tf.min > lf.min){
return -1;
}
if(df.month<hf.month || tf.min < lf.min){
return 1;
}
if(df.dat>hf.dat || tf.sec > lf.sec){
return -1;
}
if(df.dat>hf.dat || tf.sec < lf.sec){
return 1;
}
if(df.dat<hf.dat || tf.sec > lf.sec){
return -1;
}
if(df.dat<hf.dat || tf.sec < lf.sec){
return 1;
}
return 0;
}
int main(){
datee d1 = { 24, 11, 30};
datee d2 = { 24, 11, 30};
timee t2 = { 10, 34, 03};
timee t1 = { 10, 33, 03};
display(d1);
display(d2);
display1(t1);
display1(t2);
int a = datetime(d1,d2,t1,t2);
printf("the dateand time compare is %d",a);
return 0;
}