forked from v100901/hackoctoberfest2020__
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPROBABLITY GAME!
85 lines (70 loc) · 1.31 KB
/
PROBABLITY GAME!
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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>
int count;
int c;
int pa;
int o;
int
main ()
{
int n;
int f;
void playgame();
printf("LET THE GAME BEGIN!!\n");
do
{
printf("ENTER THE NUMBER OF TIMES YOU WANT TO PLAY!:\n");
scanf ("%d", &c);
printf("DO YOU WANT TO PLAY WITH THE PREVIOUS AMOUNT(1/0)\n");
scanf("%d",&f);
if(f==0)
{
printf ("ENTER YOUR AMOUNT:\n");
scanf ("%d", &count);
playgame();
printf ("WANT TO PLAY MORE(1/0)?");
scanf ("%d", &o);
}
else if(f==1)
{
FILE*a;
a=fopen("M5.txt","w");
int w=getw(a);
printf("YOUR PREVIOUS SCORE IS %d\n",w);
count=w;
playgame();
printf ("WANT TO PLAY MORE(1/0)?");
scanf ("%d", &o);
fclose(a);
}
}
while (o == 1);
if(o==0)
printf("THANKS FOR PLAYING WITH US!!");
printf("YOUR FINAL SCORE IS %d",count);
return 0;
}
void playgame ()
{
for (int n = c-1; n >= 0; --n)
{
int x;
printf ("ENTER YOUR NUMBER:\n");
scanf ("%d", &x);
int k = rand () % 2;
printf ("COMPUTER CHOSE: %d\n", k);
if (x == k)
{
printf ("YOU WON!!\n");
count = count + 500;
}
else
{
printf ("YOU LOSE!!\n");
count = count - 500;
}
printf ("ONLY %d TRIES LEFT!!!\n", n);
}
}