פורסם 2012 בנובמבר 2813 שנים בניתי תוכנית של C שהיא קזינו, עשיתי כזה דבר שכאשר המשתמש מכניס 1 זה יכניס אותו למשחק סלוטים וכאשר לוחץ 2 יכניס אותו לרולטה.כאשר המשתמש לוחץ 2 הכל עובד הרולטה עובדת כאשר המשתמש לוחץ 1, זה כותב פלט כלשהוא מהתוכנית ואני לא מבין למה הנה החלק הראשון של התוכנית: (תתעלמו מהגוטו בהתחלה): דא התוכנית מביאה אותי תמיד ל: printf("Your Money at the moment is:%d",CASH);#include <stdio.h>#include <stdlib.h>#include <math.h>#include <time.h>void main(){ int slots,bet_slots,choosing_game,CASH=100; startgame: printf("Welcome to our Casino, please press 1 for slots or 2 for roullete: \n"); scanf("%d", &choosing_game); //Picking which game you want to play slots or roulette. if(choosing_game==1) { // He Picked 1, so it will be a slot game. char a; //One Char, #, $ ,%. char b; //Second Char, #, $, %. char c; //Third Char, #, $, %. while(CASH>=20) { work: printf("You chose slots game, your first bet kit value is 100$ please enter a bet that's above 20$"); // The work here is for GOTO. scanf("%d", &bet_slots); //The bet money. if(bet_slots>20) //If the user's bet was higher than 20, because it's a condition for the Casino. { srand( (unsigned int) time(NULL)); a = rand() % 3; //Enters a random number from 0 to 2 to the Char A. b = rand() % 3; //Enters a random number from 0 to 2 to the Char B. c = rand() % 3; //Enters a random number from 0 to 2 to the Char C. if (a==b==c==0||a==b==c==1||a==b==c==2) //Checks if the user even won in some way ### or $$$ or %%%. { if (a==b==c==0) // ### { printf("# # #, YOU WON!!!"); CASH=bet_slots*8-bet_slots; printf("Slot Machine result: %c%c%c \n", a,b,c); printf("Your Money at the moment is:%d",CASH); //Shows the money that the user still have. } if (a==b==c==1) // $$$ { printf("$ $ $, YOU WON!!!"); CASH=bet_slots*8-bet_slots; printf("Slot Machine result: %c%c%c \n", a,b,c); printf("Your Money at the moment is:%d",CASH); //Shows the money that the user still have. } if (a==b==c==2) // %%% { printf("% % %, YOU WON!!!"); CASH=bet_slots*8-bet_slots; printf("Slot Machine result: %c%c%c \n", a,b,c); printf("Your Money at the moment is:%d",CASH); //Shows the money that the user still have. } } else { printf("You lost your game, better luck next time.\n"); CASH=CASH-bet_slots; printf("Slot Machine result: %c%c%c \n",a,b,c); printf("Your Money at the moment is:%d",CASH); //Shows the money that the user still have. } } else { printf("Sry, your bet needs to be higher than 20$!"); goto work; //The goto will take him up to the start of the slots. printf("Your Money at the moment is:%d",CASH); //Shows the money that the user still have. } }}
פורסם 2012 בנובמבר 2813 שנים ערוך את ההודעה ושים את הקוד בתוך טג קוד (כפתור עם ציור #) כדי שיהיה קריא.
ארכיון
דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.