Me ayudan por favor, es para un proyecto de la facultad!
#include <iostream> using namespace std; #include <cstdlib> #include <ctime> #include <string.h> #include "rutinas.h" int main() { //MENU int opcion; // OPCION 1 int r, pts, total=0, suma; int dados[5]; int mati[3][5]; char nombre[30]; //char resp[3]; //char yes[]="SI"; //INICIO MENU GENERALA while(true) { system("cls"); cout << "ttttt GENERALA " << endl; cout << "----------------------------------------------------------------------------------------------------" << endl; cout << "ntttt 1 - JUEGO NUEVO PARA UN JUGADOR" << endl; cout << "ntttt 2 - JUEGO NUEVO PARA DOS JUGADORES" << endl; cout << "ntttt 3 - MOSTRAR PUNTUACION MAS ALTA" << endl; cout << "ntttt 0 - SALIR DEL JUEGO" << endl; cout << endl; cout << "n t t t t OPCION: "; cin >> opcion; switch(opcion) { case 1: system("cls"); cout << "NOMBRE DEL JUGADOR: "; cin >> nombre; strupr(nombre); system("cls"); srand(time(NULL)); // PARA GENERAR NUMEROS AL AZAR //INICIO DE PARTIDA for(r=1;r<=3;r++){ //tirarDadosTrucho(dados, 5); tirarDados(dados, 5); mostrarDados(dados, 5); guardarRonda(mati, dados, r); repetirTiro(dados); guardarRonda(mati, dados, r); suma = sumarVector(dados, 5); total += suma; cout << endl << endl << "PUNTAJE: "; cout << total << endl; system("pause"); cout << endl; } system("cls"); cout << "FELICITACIONES " << nombre << ", " << endl; cout << "TU PUNTAJE FINAL ES " << total; cout << endl << endl; mostrarJuego(mati); /*categoriaNumeros(dados); categoriaGenerala(dados); categoriaPoker(dados); categoriaFull(dados, 5); mostrarJuego(mati);*/ system("pause"); break; case 2: system("cls"); system("pause"); break; case 3: system("pause"); break; case 0: return 0; //system("pause"); break; default: system("cls"); cout << "nntttt POR FAVOR, INGRESE UNA OPCION CORRECTA" << endl; cout << endl << endl; system("pause"); } } //FIN MENU GENERALA system("pause"); return 0; } rutinas: // solo para separar el main del header void tirarDadosTrucho(int *vec, int tam) { int i; for(i=0; i<tam; i++) { cin >> vec[i]; } cout << endl; } void tirarDados(int *vec, int tam) { int i; for(i=0; i<tam; i++) { vec[i] = (rand()%6)+1; } cout << endl; } void mostrarDados(int *vec, int tam) { int i; cout << endl; cout << " --------- --------- --------- --------- --------- " << endl; cout << " | | | * | | * | | * * | | * * |" << endl; cout << " | * | | | | * | | | | * |" << endl; cout << " | | | * | | * | | * * | | * * |" << endl; cout << " --------- --------- --------- --------- --------- " << endl; cout << " DADO 1 DADO 2 DADO 3 DADO 4 DADO 5 " << endl; for(i=0; i<tam; i++) { cout << "t" << vec[i] << "t"; } cout << endl << endl; } void repetirTiro(int *vec) { int cDados; char respuesta[5]; char si[]={"si"}; bool repetir=true; while(repetir==true) { cout << endl << "DESEA VOLVER A TIRAR LOS DADOS? : "; cin >> respuesta; if(strcmp(respuesta,si)==0) { cout << "CUANTOS DADOS DESEA VOLVER A TIRAR: "; cin >> cDados; cout << endl; if(cDados==1) { cout << " --------- " << endl; cout << " | |" << endl; cout << " | * |" << endl; cout << " | |" << endl; cout << " --------- " << endl; cout << " DADO 1 " << endl; } else if(cDados==2) { cout << endl; cout << " --------- --------- " << endl; cout << " | | | * |" << endl; cout << " | * | | |" << endl; cout << " | | | * |" << endl; cout << " --------- --------- " << endl; cout << " DADO 1 DADO 2 " << endl; } else if(cDados==3) { cout << endl; cout << " --------- --------- --------- " << endl; cout << " | | | * | | * |" << endl; cout << " | * | | | | * |" << endl; cout << " | | | * | | * |" << endl; cout << " --------- --------- --------- " << endl; cout << " DADO 1 DADO 2 DADO 3 " << endl; } if(cDados==4) { cout << endl; cout << " --------- --------- --------- --------- " << endl; cout << " | | | * | | * | | * * |" << endl; cout << " | * | | | | * | | |" << endl; cout << " | | | * | | * | | * * |" << endl; cout << " --------- --------- --------- --------- " << endl; cout << " DADO 1 DADO 2 DADO 3 DADO 4 " << endl; } else if(cDados==5) { cout << endl; cout << " --------- --------- --------- --------- --------- " << endl; cout << " | | | * | | * | | * * | | * * |" << endl; cout << " | * | | | | * | | | | * |" << endl; cout << " | | | * | | * | | * * | | * * |" << endl; cout << " --------- --------- --------- --------- --------- " << endl; cout << " DADO 1 DADO 2 DADO 3 DADO 4 DADO 5 " << endl; } //DESPUES DE INDICAR for(int d=0; d<cDados; d++) { vec[d] = (rand()%6)+1; } for(int z=0; z<cDados; z++) { cout << "t" << vec[z] << "t"; } cout << endl << endl; } else if(strcmp(respuesta,si)==1) { repetir=false; } } } int sumarVector(int *v, int tam) { int i, s=0; for(i=0; i<tam; i++) { s+=v[i]; } return s; } int contarValor(int *vec, int tam, int valorBuscado, int valorBuscado2, int valorBuscado3, int valorBuscado4, int valorBuscado5, int valorBuscado6) { int i; int c=0; for(i=0; i<tam; i++) { if((vec[i]==valorBuscado)||(vec[i]==valorBuscado2)||(vec[i]==valorBuscado3)||(vec[i]==valorBuscado4)||(vec[i]==valorBuscado5)||(vec[i]==valorBuscado6)) { c++; } } return c; } void categoriaNumeros(int *vec) { int i, i2, i3, i4, i5 , i6; int c, cant; int ptos1=0, ptos2=0, ptos3=0, ptos4=0, ptos5=0, ptos6=0; for(c=1; c<6; c++) { cant = contarValor(vec, 5, i, i2, i3, i4, i5, i6); if(vec[c]==i) { ptos1 += i; } if(vec[c]==i2) { ptos2 = i2*2; } if(vec[c]==i3) { ptos3 = i3*3; } if(vec[c]==i4) { ptos4 = i4*4; } if(vec[c]==i5) { ptos5 = i5*5; } if(vec[c]==i6) { ptos6 = i6*6; } } cout << endl << endl; cout << "PUNTOS 1: " << ptos1 << endl << endl; cout << "PUNTOS 2: " << ptos2 << endl << endl; cout << "PUNTOS 3: " << ptos3 << endl << endl; cout << "PUNTOS 4: " << ptos4 << endl << endl; cout << "PUNTOS 5: " << ptos5 << endl << endl; cout << "PUNTOS 6: " << ptos6 << endl << endl; } // FIN CATEGORIA DE NUMEROS void categoriaGenerala(int *vec) { int i; int cant; for(i=1; i<=6; i++) { cant = contarValor(vec, 5, i, i, i, i, i, i); if(cant == 5) { cout << "GENERALA - 60 PUNTOS!" << endl << endl; } } } //FIN CATEGORIA GENERALA void categoriaPoker(int *vec) { int i; int cant; for(i=1; i<=6; i++) { cant = contarValor(vec, 5, i, i, i, i, i, i); if(cant == 4) { cout << "POKER - 40 PUNTOS!" << endl << endl; } } } //FIN CATEGORIA POKER void categoriaFull(int *vec) { } //FIN CATEGORIA FULL bool categoriaEscalera(int *vec) { bool escalera=true; int posmin, aux, ant; //MUESTRA POR PANTALLA ANTES DE ORDENAMIENTO cout << "ANTES DE ORDENAR"<<endl; cout << "--------------------------------------------------------------------------------"; //ORDENAMIENTO DE VECTOR for(int z=0; z<5-1; z++) { posmin=z; for(int y=z+1; y<5; y++) { if(vec[y]<vec[posmin]) { posmin=y; } } aux=vec[z]; vec[z]=vec[posmin]; vec[posmin]=aux; } //MUESTRA POR PANTALLA DESPUES DE ORDENAMIENTO cout << "DESPUES DE ORDENAR" << endl << endl; for(int a=0; a<5; a++) { cout << vec[a] << endl; } cout << endl; //COMPORBACION DE ESCALERA ant=vec[0]; for(int x=0; x<5; x++) { if(x!=0) { if (vec[x] == ant+1) { } else { escalera = false; x=800; } } ant = vec[x]; } if(escalera==true) { cout << "ESCALERA: APARECEN NUMERO CONSECUTIVOS " << endl; cout << endl; return true; } return false; } //FIN CATEGORIA ESCALERA void guardarRonda(int m[3][5], int *dados, int ronda) { int i; for(i=0; i<5; i++) { m[ronda-1][i] = dados[i]; } } void mostrarJuego(int mat[3][5]) { int i, j; for(i=0; i<3; i++) { cout << "RONDA " << i+1 << " : "; for(j=0; j<5; j++) { cout << mat[i][j] << " "; } cout << endl; } cout << endl; }