blob: 8c7153418e52ba810555b4be8ebb8ffbe574415b (
plain)
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
|
#include <tice.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define EnterKey 5
#define ExitKey 9
int coinFlip(void);
int main()
{
while (true) {
os_ClrHome();
printf("Coin Flip\nPress Enter to Flip\nPress Clear to exit\n");
int key = os_GetKey();
if (key == ExitKey)
break;
int coin = coinFlip();
if (coin == 0)
printf("Heads");
else if (coin == 1)
printf("Tails");
while (!os_GetCSC());
}
return 0;
}
int coinFlip(void)
{
time_t t;
srand((unsigned) time(&t));
return (rand() % 2);
}
|