-
Notifications
You must be signed in to change notification settings - Fork 0
/
struct2.c
38 lines (36 loc) · 1007 Bytes
/
struct2.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
#include <stdio.h>
main() {
struct date {
int day, month, year;
} today, tomorrow;
puts("MENCARI NILAI TANGGAL");
fflush(stdin);
printf("\nMasukkan tanggal sekarang [dd-mm-yyyy): ");
scanf("%d-%d-%d", &today.day, &today.month, &today.year);
tomorrow = today;
tomorrow.day++;
if (today.month == 1 || today.month == 3 || today.month == 5 || today.month == 7 || today.month == 8 || today.month == 10 || today.month == 12) {
if (today.day == 31) {
if (today.month == 12)
tomorrow.day = 1, tomorrow.month = 1, tomorrow.year++;
else
tomorrow.day = 1, tomorrow.month++;
}
}
else {
if (today.month == 2) {
if (today.year % 4 != 0) {
if (today.day == 28)
tomorrow.day = 1, tomorrow.month++;
}
else {
if (today.day == 29)
tomorrow.day = 1, tomorrow.month++;
}
}
else
if (today.day == 30)
tomorrow.day = 1, tomorrow.month++;
}
printf("Besoknya: %d-%d-%d\n", tomorrow.day, tomorrow.month, tomorrow.year);
}