Sunteți pe pagina 1din 2

#include<stdio.

h>
#include<conio.h>
#include<stdint.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>

//Elmo Tanu Miharja @elmotan95 1701296454 IT MAT BINUS

int main(){

char name[25];
char* horse[10][50];
horse[0][50]="Black";
horse[1][50]="Blue";
horse[2][50]="Cyan";
horse[3][50]="Green";
horse[4][50]="Red";
horse[5][50]="Pink";
horse[6][50]="Yellow";
horse[7][50]="Gold";
horse[8][50]="Silver";
horse[9][50]="Platinum";
int money=1000;
int numhorse;
int y=0,z=0;
int bethorse;
int speed,arr_speed[100];
int temp=0;

printf("TEST MODE\n");
printf("Welcome to Bao Horse Racing...");
printf("\n\nPlease Register to Start Racing... ^^\n\n");
printf("===========================================");
printf("\n\nRegistration\n");
printf("************\n\n");
do{
printf("Input your name [2..25]: ");
gets(name);
fflush(stdin);
}while(strlen(name)<2 || strlen(name)>25);

printf("\n\nPress ENTER to Continue..\n\n\n");


getchar();

do{
srand(time(NULL));

system("cls");
printf("Available Horse: \n\n");

for(int x=0 ; x<10 ; x++){


speed = rand()%16+25;
arr_speed[x]=speed;
printf("%d. %s \n",x,horse[x][50]);
//printf("%d. %s with speed %d\n",x,horse[x][50],arr_speed[x]);
}
printf("\n\nYour Money: %d",money);
//printf("==============DEBUG================");
printf("\n\nInput horse number: ");
scanf("%d",&numhorse);
fflush(stdin);
printf("\n\nInput your betting monney: ");
scanf("%d",&bethorse);
fflush(stdin);
//printf("==============DEBUG================");
getchar();
system("cls");
//printf("==============DEBUG================");
y = numhorse;
printf("\n\nYou choose: %s",horse[y][50]);
//printf("\n\nYou choose: %s with speed %d",horse[y][50],arr_speed[y]);
printf("\n\nYou Bet : $%d",bethorse);
getchar();
//printf("==============DEBUG================");
//skip
system("cls");
//printf("==============DEBUG================");
for(int d=0; d<10;d++){
if(arr_speed[d]>arr_speed[y]||arr_speed[d]==arr_speed[y]){
temp=1;
//printf("\nKuda kamu yaitu kuda kec %d kalah terhadap kuda kec
%d (result temp=%d)",arr_speed[y],arr_speed[d],temp);

}else
temp=0;
//printf("\nKuda kamu yaitu kuda kec %d menang terhadap kuda kec
%d (result temp=%d)",arr_speed[y],arr_speed[d],temp);
}
//printf("\nresult temp: %d",temp);
//printf("==============DEBUG================");
if(temp==0){
printf("\nSelamat, kuda kamu paling cepat");
printf("\nYou get %d",bethorse);
money+=bethorse;
printf("\nYour money now %d\n\n",money);

}else if(temp==1){
printf("\nCops, kuda kamu paling pelan");
printf("\nYou lost %d",bethorse);
money-=bethorse;
printf("\nYour money now %d",money);
}
getchar();
}while(money>=-1);

getchar();
return 0;

S-ar putea să vă placă și