-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoulette.c
More file actions
333 lines (295 loc) · 10.9 KB
/
Copy pathRoulette.c
File metadata and controls
333 lines (295 loc) · 10.9 KB
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
void bettingList();
//int countSt
int main(void) {
int bank = 100;
int bet;
int betChoice;
int black[18] = {2,4,6,8,10,11,13,15,17,20,22,24,26,28,29,31,33,35};
int red[18] = {1,3,5,7,9,12,14,16,18,19,21,23,25,27,30,32,34,36};
int single = -1;
int bets [5][2];
int numBets;
int i, r, b, cont;
char output[3000];
int index =0;
do{
srand(time(NULL));
r = rand() % 38;
printf("You may bet up to five times.\nHow many bets would you like to make?");
scanf("%d", &numBets);
for(i = 0; i < numBets; i++)
{
bets[i][0] = -1;
bets[i][1] = 0;
}
if(numBets < 1 || numBets >5)
{
numBets = 0;
printf("Invalid entry. Try again.\n");
printf
}
for (i = 0; i < numBets; i++)
{
bettingList();
printf("Choose what you would like to bet on.");
scanf("%d", &betChoice);
while(betChoice <1 || betChoice > 14)
{
betChoice = -1;
printf("Invalid entry. Try again.\nWhat would you like to bet on? ");
scanf("%d", &betChoice);
}
if(betChoice == 13)
{
printf("What number would you like to bet on?\nIf you would like to bet on '00', enter '38'. ");
scanf("%d", &single);
if(single < 0 || single > 38)
{
single = -1;
printf("Invalid entry. Try again.\n");
printf("What number would you like to bet on?\nIf you would like to bet on '00', enter '38'. ");
scanf("%d", &single);
}
}
printf("How much would you like to bet? ($1 - $5) ");
scanf("%d", &bet);
while(bet < 1 || bet > 5)
{
bet = 0;
printf( "Invalid entry. Try again.\nHow much would you like to bet? ");
scanf("%d", &bet);
}
strcat(output, "%d\n", r);
switch(betChoice)
{
case 1:
if(r >= 1 && r <= 18)
{
strcat(output, "You won your bet on low numbers!\n");
bank += bet;
}
else
{
strcat(output, "You lost your bet on low numbers.\n");
bank -= bet;
}
break;
case 2:
if(r >= 19 && r <= 36)
{
strcat(output, "You won your bet on high numbers!\n");
bank += bet;
}
else
{
strcat(output, "You lost your bet on high numbers.\n");
bank -= bet;
}
break;
case 3:
b = 0;
for(i = 0; i < 18; i++)
{
if(r == red[i])
{
b = 1;
strcat(output, "You won your bet on red numbers!\n");
bank += bet;
}
}
if(!b)
{
strcat(output, "You lost your bet on red numbers.\n");
bank -= bet;
}
break;
case 4:
b = 0;
for(i = 0; i < 18; i++)
{
if(r == black[i])
{
b = 1;
strcat(output, "You won your bet on black numbers!\n");
bank += bet;
}
}
if(!b)
{
strcat(output, "You lost your bet on black numbers.\n");
bank -= bet;
}
break;
case 5:
if(r % 2 == 0)
{
strcat(output, "You won your bet on even numbers!\n");
bank += bet;
}
else
{
strcat(output, "You lose your bet on even numbers.\n");
bank-=bet;
}
break;
case 6: //Odd Numbers
if(r % 2 != 0)
{
strcat(output, "You won your bet on odd numbers!\n");
bank += bet;
}
else
{
strcat(output, "You lose your bet on odd numbers.\n");
bank-=bet;
}
break;
case 7: //First Dozen
if(r <= 12)
{
strcat(output, "You won your bet on the First Dozen numbers!\n");
bank += (bet*2);
}
else
{
strcat(output, "You lose your bet on the First Dozen numbers.\n");
bank-=(bet*2);
}
break;
case 8: //Second Dozen
if(r >= 13 && r <= 24)
{
strcat(output, "You won your bet on the Second Dozen numbers\n");
bank += (bet*2);
}
else
{
strcat(output, "You lose your bet on the Second Dozen numbers.\n");
bank-=(bet*2);
}
break;
case 9: //Third Dozen
if(r >= 25 && r <= 36)
{
strcat(output, "You won your bet on the Third Dozen numbers!\n");
bank += (bet*2);
}
else
{
strcat(output, "You lose your bet on the Third Dozen numbers.\n");
bank-=(bet*2);
}
break;
case 10: //First Column
if(r % 3 == 1)
{
strcat(output, "You won your bet on the First Column numbers!\n");
bank += (bet*2);
}
else
{
strcat(output, "You lose your bet on the Third Dozen numbers.\n");
bank-=(bet*2);
}
break;
case 11:
if(r % 3 == 2)
{
strcat(output, "You won your second column bet!\n");
bank += (2 * bet);
}
else
{
strcat(output, "You lost your second column bet.\n");
bank -= bet;
}
break;
case 12:
if(r % 3 == 0)
{
strcat(output, "You won your third column bet!\n");
bank += (2 * bet);
}
else
{
strcat(output, "You lost your third coulmn bet.\n");
bank -= bet;
}
break;
case 13:
if(r == single)
{
strcat(output, "You won your single bet!\n");
bank += (35 * bet);
}
else
{
strcat(output, "You lost your single bet.\n");
bank -= bet;
}
break;
case 14:
if (r == 0 || r == 1 || r == 2 || r ==3)
{
strcat(output, "You own your basket bet!");
bank += (11 * bet);
}
else
{
strcat(output, "You lost your basket bet.\n");
bank -= bet;
}
break;
case 15:
if (r == 0 || r == 38 || r == 1 || r == 2 || r ==3)
{
strcat(output, "You won your top line bet!\n");
bank += (6 * bet);
}
else
{
strcat(output, "You lost your top line bet.\n");
bank -= bet;
}
break;
default:
break;
}
printf( "your current bank amount is: %d\n", bank);
}
printf( "Do you want to play again?\nEnter 1 to play again and 0 to exit. ");
scanf("%d", &cont);
}while(cont);
return 0;
}
void bettingList()
{
printf( "===============\n");
printf( "Betting Options\n");
printf( "===============\n\n");
printf( "============\n");
printf("Outside Bets\n");
printf( "============\n");
printf( "1. Low (1-18)\n");
printf( "2. High (19-36)\n");
printf("3. Red\n");
printf( "4. Black \n");
printf( "5. Even \n");
printf( "6. Odd \n");
printf( "7. First Dozen (1-12)\n");
printf( "8. Second Dozen (13-24)\n");
printf( "9. Third Dozen (25-36)\n");
printf( "10. First Column (1, 4, 7, ..., 34)\n");
printf( "11. Second Column (2, 5, 8, ..., 35)\n");
printf( "12. Third Column (3, 6, 9, ..., 36)\n\n");
printf( "===========\n");
printf( "Inside Bets\n");
printf( "===========\n");
printf( "13. Single\n");
printf( "14. Basket (0, 1, 2, 3)\n");
printf( "15. Top Line (0, 00, 1, 2, 3)\n");
}