-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tugas2e.c
101 lines (97 loc) · 2.8 KB
/
Tugas2e.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
int main()
{
int a, b, c, d, e, f, g, h, i, j, k, l, m, n, tdk;
char z;
do
{
printf("\n=== Game Tebak Angka ===\n\n");
printf("Pikirkan Angka Dari 1-20\n");
srand(time(0));
a = rand() % 20;
b = rand() % 20;
c = rand() % 20;
d = rand() % 20;
e = rand() % 20;
printf("%d %d %d %d %d\n", a, b, c, d, e);
printf("Apakah angka mu ada di antara deret angka ini? ");
scanf(" %c", &z);
if (z == 't')
while (z == 't')
{
a = rand() % 20;
b = rand() % 20;
c = rand() % 20;
d = rand() % 20;
e = rand() % 20;
printf("%d %d %d %d %d\n", a, b, c, d, e);
printf("Apakah angka mu ada di antara deret angka ini? ");
scanf(" %c", &z);
}
if (z == 'y')
{
f = rand() % 20;
printf("%d %d %d %d %d\n", f, b, c, d, e);
printf("Apakah angka mu ada di antara deret angka ini? ");
scanf(" %c", &z);
if (z == 't')
{
printf("Angkamu Ialah %d\n", a);
}
}
if (z == 'y')
{
g = rand() % 20;
printf("%d %d %d %d %d\n", f, g, c, d, e);
printf("Apakah angka mu ada di antara deret angka ini? ");
scanf(" %c", &z);
if (z == 't')
{
printf("Angkamu Ialah %d\n", b);
}
}
if (z == 'y')
{
h = rand() % 20;
printf("%d %d %d %d %d\n", f, g, h, d, e);
printf("Apakah angka mu ada di antara deret angka ini? ");
scanf(" %c", &z);
if (z == 't')
{
printf("Angkamu Ialah %d\n", c);
}
}
if (z == 'y')
{
i = rand() % 20;
printf("%d %d %d %d %d\n", f, g, h, i, e);
printf("Apakah angka mu ada di antara deret angka ini? ");
scanf(" %c", &z);
if (z == 't')
{
printf("Angkamu Ialah %d\n", d);
}
}
if (z == 'y')
{
j = rand() % 20;
printf("%d %d %d %d %d\n", f, g, h, i, j);
printf("Apakah angka mu ada di antara deret angka ini? ");
scanf(" %c", &z);
if (z == 't')
{
printf("Angkamu Ialah %d\n", e);
}
if (z == 'y')
{
printf("Angkamu Ialah %d\n", j);
}
}
else if (z != 'y' && z != 't')
{
printf("Masukkan Yang Benar");
}
} while (z == 'y' || z == 't' || z != 'y' || z != 't');
}