קוד:
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
int main()
{
const int slots = 1;
const int roullete = 2;
const int bingo = 3;
const int exit = 0;
float cashbox = 100 ;
int unused[101];
int matrix[5][5];
int choice = 0;
int sumOfHimur = 0;
int choice2 = 0;
int i,j;
int num1;
srand(time(NULL));
do
{
printf("welcome to the dark side of the moon casino\n");
printf("We hope to realize a dream for you\n\n");
printf("what game would you like to play?\n");
printf("1 - slots\n");
printf("2 - roullete\n");
printf("3 - bingo\n\n");
printf("0 - exit\n");
printf("please enter your choice:");
scanf("%d", &choice);
if(choice == slots)
{
printf("welcome to slots\n");
printf("your current balance is: %f\n", cashbox );
printf("please enter your current bet <20 - 100.00>:");
scanf("%d", &sumOfHimur);
if((sumOfHimur <= cashbox)&&(sumOfHimur >= 20))
{
int num1= rand()%3+35;
int num2= rand()%3+35;
int num3= rand()%3+35;
printf("%c ",num1);
printf("%c ",num2);
printf("%c\n",num3);
if((num1==num2)&&(num2==num3)&&(num1==num3))
{
cashbox=cashbox-sumOfHimur;
sumOfHimur= sumOfHimur*8;
cashbox=cashbox+sumOfHimur;
printf("you won %d dollars\n\a", sumOfHimur);
printf("your current balance is: %f\n", cashbox );
}
else
{
cashbox=cashbox-sumOfHimur;
printf("you lose\?");
printf("your current balance is: %f\n", cashbox );
}
}
else
{
printf("your bet is wrong\n");
}
}
else if(choice==roullete)
{
printf("welcome to roullete\n");
printf("your current balance is: %f\n", cashbox );
printf("please enter your current bet <20 - 100.00>:");
scanf("%d", &sumOfHimur);
if((sumOfHimur <= cashbox)&&(sumOfHimur >= 20))
{
printf("enter number Between 1-36 ");
scanf("%d", &choice2);
if((choice2<37)&&(choice2>0))
{
int num1=1;
if(num1==choice2)
{
cashbox=cashbox-sumOfHimur;
sumOfHimur= sumOfHimur*35;
cashbox=cashbox+sumOfHimur;
printf("The winning number is %d\n", num1);
printf("you won %d dollars\n\a", sumOfHimur);
printf("your current balance is: %f\n", cashbox );
}
else
{
cashbox=cashbox-sumOfHimur;
printf("you lose\n");
printf("your current balance is: %f\n", cashbox );
}
}
else
{
printf("the number you choice is wrong\n");
}
}
else
{
printf("your bet is wrong\n");
}
}
if(choice==bingo)
{
printf("welcome to bingo ");
printf("your current balance is: %f\n", cashbox );
printf("please enter your current bet <20 - 100.00>:");
scanf("%d", &sumOfHimur);
if((sumOfHimur <= cashbox)&&(sumOfHimur >= 20));
{
for(i=0;i<=100;++i)
{
unused[i]=0;
}
for(i=0;i<5;++i)
{
for(j=0;j<5;++j)
{
while(unused == 0)
{
num1=rand()%100+1;
if(unused[num1]==0)
{
matrix[i][j]=num1;
unused[num1]=1;
}
}
printf("%d ", matrix[i][j]);
}
printf("\n");
}
}
}
else
{
printf("Wrong choice the game you want does not exist\n");
}
}
if(choice!=exit);
printf("goodbey and see you soon\n");
while(choice!=exit);
system("pause");
return(0);
}