Código
//Simulacion del Juego de Cartas BLACKJACK //AUTOR: ANTONIO GONZALEZ\\\IDE=DEV C++ #include <iostream> #include <conio.h> #include <stdlib.h> #include <time.h> #include <windows.h> /* ................DECLARACION DE FUNCIONES Y VARIABLES.......................*/ bool validarjugadores(int); int cartadebaraja(int,int); int ingresodejugadores(int); int instrucciones(int); int apuesta(int,int); int cartasobtenidas(int,int); char tipocarta(char); int jugadores,cantidad,mensaje,op; int lista1[4]; /* ..............................MENU_INICIO..................................*/ int main();{ system("color f0"); cout<<"\n\t\t\tSIMULACION BLACKJACK"<<endl; cout<<" ----------------------------------" <<endl; cout<<"| MENU |"<<endl; cout<<" ----------------------------------" <<endl; cout<<"|1. LEER INSTRUCCIONES |"<<endl; cout<<"|2. NUMERO DE JUGADORES Y REGISTRO |"<<endl; cout<<"|3. INGRESAR SUS APUESTAS |"<<endl; cout<<"|4. A JUGAR! |"<<endl; cout<<" ---------------------------------- "<<endl; cout<<"| Seleccione una opcion: 1->4 | |"<<endl; cout<<" ---------------------------------- "<<endl; gotoxy(36,45); cin>>op; /* OPCION 1 - INSTRUCCIONES...................................................*/ switch(op) { case 1: system("color b4"); mensaje=instrucciones(instru); brake; system("pause"); /* OPCION 2 - REGISTRO DE JUGADORES(CANTIDAD Y NOMBRE)........................*/ case 2: system("color e8"); int jugadores; jugadores=ingresodejugadores(jugador,contrincante) brake; system("pause"); /* OPCION 3 - INGRESO DE APUESTAS(MONEY)......................................*/ case 3: system("color f9"); cant=apuesta(cantjug,cantcontri); brake; system("pause"); /* OPCION 4 - JUEGO(METODO PRINCIPAL) ........................................*/ case 4: system("color f0"); cout<<"Tu primera carta es: "<<tipo<<carta1; cout<<"Tu segunda carta es: "<<tipo<<carta2; escogidas=cartasdebaraja(carta1,carta2) if(resultado==21){ cout<<"BLACKJACK! !VICTORIA"<<sumadas; cout<<"TE LLEVAS TODO ESTO DE LA APUESTA Q. "<<cant; } else(resultado<21){ cout<<"PERDISTE"; } brake; system("pause"); } /* F */ /* U */ /* N */ /* C */ /* I */ /* O */ /* N */ /* E */ /* S */ /* ....................VALIDAR CANTIDAD DE JUGADORES..........................*/ bool validarjugadores(int cantidad) {int cantidad; if (cantidad==0) && (cantidad>2){ return false; } else{ return true; } } /* ........................INSTRUCCIONES DEL JUEGO............................*/ int instrucciones(int instru) { cout<<"\t 1. Debe ingresar 2 jugadores y registrar su NICKNAME"<<endl; cout<<"\t 2. Debe apostar almenos Q.100"<<endl; cout<<"\t 3. Se le proporcionaran 2 cartas de un mazo aleatoriamente"<<endl; cout<<"\t 4. Quien saque la suma de 21 gana la partida y el dinero"<<endl; cout<<"\t 5. si saca un numero mayor que 21 pierde automaticamente"<<endl<<endl<<endl; return mensaje; } /* ........................RECAUDACION DE APUESTAS............................*/ int apuesta(int cantjug,int cantcontri){ int cantjug,cantcontri=0; cout<<"\t\nMinimo: Q.100 --- Maximo:Q.500"<<endl<<endl; cout<<"\t\tCuanto Apuestas tu Q. "<<endl; cin>>cantjug; cout<<"\t\tCuanto Apostaras contrincante Q. "<<endl; cin>>cantcontri; cant=cantjug+cantcontri return cant; } /* ...........................REGISTRAR JUGADORES......,......................*/ int ingresodejugadores(int jugador,int contrincante) { do { cout<<"INGRESE LA CANTIDAD DE JUGADORES DE ESTA PARTIDA"<<endl; cin>>cantidad; } while(validarjugadores(cantidad)) cout<<"\n\t\t\tINGRESE SU NICKNAME RETADOR_: "<<jugador<<endl; cout<<"\n\t\t\tINGRESE SU NICKNAME CONTRINCANTE_: "<<contrincante<<endl; return jugadores; } /* ...................CARTAS SELECCIONADAS PARA JUGADORES.....................*/ int cartadebaraja(int carta1,int carta2){ srand(time(NULL)); int carta1,carta2=0; carta1=(rand()%13)+1; carta2=(rand()%13)+1; resultado=carta1+carta2; return resultado; } /*............................................................................*/ int tipocarta(char lista1[]){ srand(time(NULL)); char tipo; lista1[]=(rand()%4)+1; tipo=lista1[]; return tipo; } /*............................................................................*/ }
· Los códigos deben ir en etiquetas GeSHi
· Los temas van en su respectivo subforo (movido)
>aquí las reglas del foro
-Engel Lex