|
| 1 | +#include<stdio.h> |
| 2 | +#include<stdlib.h> |
| 3 | +#include<time.h> |
| 4 | +int n,b,r,*a; |
| 5 | + |
| 6 | +void start(){ |
| 7 | + srand(time(0)); |
| 8 | + |
| 9 | + a = (int*)malloc(3*sizeof(int)); |
| 10 | + *a=rand()%3; |
| 11 | + *(a+1)= rand()%3; |
| 12 | + *(a+2)= rand()%3; |
| 13 | + |
| 14 | + if(n>0){ |
| 15 | + |
| 16 | + printf("you have currently $%d \n",n); |
| 17 | + printf("enter the bet amount $"); |
| 18 | + scanf("%d",&b); |
| 19 | + if(b<=n){ |
| 20 | + printf("find the place of queen[chose 1,2,3] : "); |
| 21 | + scanf("%d",&r); |
| 22 | + if(*a==(r-1) ){ |
| 23 | + printf("congratulations you win!\n"); |
| 24 | + n=n-b+(3*b); |
| 25 | + printf("now you have $%d\n",n); |
| 26 | + printf("______________________________\n"); |
| 27 | + } |
| 28 | + else{ |
| 29 | + printf("Better luck Next time\n"); |
| 30 | + n=n-b; |
| 31 | + printf("now you have $%d \n",n); |
| 32 | + printf("______________________________\n"); |
| 33 | + } |
| 34 | + }else{ |
| 35 | + printf("you have only $%d and you Bet $%d \n",n,b); |
| 36 | + |
| 37 | + } |
| 38 | + |
| 39 | + } |
| 40 | + else{ |
| 41 | + printf("you are not eligible to play game \n you ave no money\n"); |
| 42 | + } |
| 43 | + free(a); |
| 44 | + |
| 45 | +} |
| 46 | +int main(){ |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +printf("______________________________\n"); |
| 51 | +printf(" BETTING GAME\n"); |
| 52 | +printf("______________________________\n"); |
| 53 | +printf(" ***** ***** *****\n"); |
| 54 | +printf(" * * * * * *\n"); |
| 55 | +printf(" * j * * Q * * K *\n"); |
| 56 | +printf(" * * * * * *\n"); |
| 57 | +printf(" ***** ***** *****\n"); |
| 58 | +printf("______________________________\n"); |
| 59 | +printf("rules : \n"); |
| 60 | +printf("1) you have to chose between 1 to 3 \n"); |
| 61 | +printf("2) you are allow to play till you have $0 \n"); |
| 62 | +printf("3) if you will win then you will get 3*(BET AMOUNT)\n\n\n"); |
| 63 | +printf("how many amount you have $"); |
| 64 | +scanf("%d",&n); |
| 65 | +int f; |
| 66 | +f=n; |
| 67 | + |
| 68 | + printf("\n\n*******************************************\n"); |
| 69 | + printf(" GAME START \n"); |
| 70 | + printf("*******************************************\n\n"); |
| 71 | +//printf("you want to play game(y/n):"); |
| 72 | +//char m; |
| 73 | +//scanf("%c",&m); |
| 74 | +while(n!=0){ |
| 75 | +start(); |
| 76 | +//printf("you want to play game again!(y/n):"); |
| 77 | +//scanf("%c",&m); |
| 78 | +} |
| 79 | +printf("\n\n\n\nyou come with $%d\n",f); |
| 80 | +printf("now you have $%d\n\n\n",n); |
| 81 | +printf("thank you for play!\n\n\n"); |
| 82 | +return 0; |
| 83 | + |
| 84 | +} |
| 85 | + |
| 86 | + |
0 commit comments