Está en la página 1de 2

#include <iostream> #include <ctime> using namespace std; int main() { int cantidad, apuesta, dados; char resp;

cout << "Ingrese la cantidad de jugadores: "; cin >> cantidad; cout << "Ingrese el valor de la apuesta: "; cin >> apuesta; cout << "Valor total de apuesta: " << cantidad * apuesta << endl; int* puntos = new int[cantidad]; int* jugadores = new int[cantidad]; srand(time(0)); for(int i = 0; i < cantidad; i++){ puntos[i] = 0; jugadores[i] = i + 1; cout << "\n= = = = = = = = = = = = = = = = = = = = =\n"; do{ if(puntos[i] < 14) dados = 2 + (rand() % 11); else dados = 1 + (rand() % 6); puntos[i] += dados; cout << "\nLanzamiento jugador " << i + 1 << ": " << dados<<endl; cout << "Puntos acumulados: " << puntos[i] << endl; if(puntos[i] > 21){ cout << "Jugador " << i + 1 << " ha perdido.\n"; break; } cout << "Desea continuar? (s/n): "; cin >> resp; }while(resp == 's'); if(puntos[i] > 21) puntos[i] = 0; } int temp; for (int i = cantidad; i >= 0; i--) for (int j = 1; j <= i; j++) if (puntos[j - 1] < puntos[j]){ temp = puntos[j]; puntos[j] = puntos[j - 1]; puntos[j - 1] = temp; temp = jugadores[j]; jugadores[j] = jugadores[j - 1]; jugadores[j - 1] = temp; } if(puntos[0] != 0){ cout << "\nGanadores: \n"; cout << "* Jugador " << jugadores[0] << ": " << puntos[0] << endl; temp = puntos[0];

for(int i = 1; i < cantidad; i++) if(puntos[i] == temp) cout << "* Jugador " << jugadores[i] << ": " << puntos[0] << endl; } else cout<<"\nNo hay ganador.\n"; delete[] puntos; delete[] jugadores; system("pause"); return 0; }

También podría gustarte