elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Arreglado, de nuevo, el registro del warzone (wargame) de EHN


  Mostrar Mensajes
Páginas: [1]
1  Programación / Programación C/C++ / ayuda con buscaminas porfavor en: 4 Mayo 2017, 18:47 pm
hola buenas tardes mi profesor nos dijo que creemos buscaminas lo pero me falta algunas cosas le precente al profesor y me dijo que nececito hacerle mejoras me dijo que lo el recuadro este al medio algo que no puedo es ocultar los numeros por asteriscos ya q si se ve los numeros no vale el juego la mina es el 7 aqui les dejo por favor ayudenme aponer asteriscos y ponerlo al medio el recuadro
Código
  1. #include <iostream>
  2. #include <ctime>
  3. #include <stdlib.h>
  4.  
  5. using namespace std;
  6. int mostrar_matriz(int[][8]);
  7.  
  8. int main () {
  9. // INICIALIZAR VALORES ALEATORIOS
  10.  
  11. srand ( (unsigned)time(NULL) );
  12.  
  13. //DECLARACION DE LA MATRIZ
  14. int matriz[8][8];
  15. int matriz_aux[8][8];
  16. int x,y,mina,salir;
  17.  
  18. //DEFINICION DE LA VARIABLE QUE REPRESENTARA A LA MINA
  19. mina=7;
  20.  
  21. //LLENADO DE LA MATRIZ CON VALORES ALEATORIOS DEL 1 AL 7
  22. for(int i = 0; i < 8; i++)
  23. {
  24. for(int j = 0; j < 8; j++){
  25. // ((MAX-MIN)+1)+MIN
  26. matriz[i][j]=rand()%((7-1)+1)+1;
  27. }
  28. }
  29.  
  30. //LLENADO DE LA MATRIZ AUXILIAR CON VALORES 0
  31. for(int i = 0; i < 8; i++)
  32. {
  33. for(int j = 0; j < 8; j++){
  34. // ((MAX-MIN)+1)+MIN
  35. matriz_aux[i][j]=0;
  36. }
  37. }
  38.  
  39.  
  40. //LLAMADA A FUNCION PARA MOSTRAR MATRIZ
  41. mostrar_matriz(matriz);
  42. cout<<endl;
  43. mostrar_matriz(matriz_aux);
  44.  
  45. do{
  46. //LECTURA DE COORDENADAS PARA ESCOGER ELEMENTO DE LA MATRIZ
  47. cout<<"las coordenadas empiezan en 0 Y concluyen en 7."<<endl;
  48. cout<<"COORDENADA X"<< endl;
  49. cin>>x;
  50. cout<<"COORDENADA X"<< endl;
  51. cin>>y;
  52.  
  53. if(x >= 0 and x <= 7 and y >= 0 and y <= 7){
  54.  
  55. if(matriz[x][y]==mina){
  56. cout<<"Fin del Juego"<<endl;
  57. salir=0;
  58. }
  59.  
  60. }else{
  61. cout<<"Coordenadas Erroneas, intente de nuevo..."<<endl;
  62. }
  63.  
  64. //AVISO PARA SALIR DEL BUCLE
  65. cout<<"Salir '1' continuar '0'"<< endl;
  66. cin>>salir;
  67. }while( salir == 0 );
  68.  
  69. cout<<"FIN DEL JUEGO..."<<endl;
  70.  
  71. system("PAUSE");
  72. return 0;
  73. }
  74.  
  75. // FUNCION QUE MUESTRA UNA MATRIZ EN PANTALLA
  76. int mostrar_matriz(int matrix[][8]){
  77. for(int i = 0; i < 8; i++)
  78. {
  79. for(int j = 0; j < 8; j++){
  80. cout<<matrix[i][j]<<" ";
  81. }
  82. cout<<endl;
  83. }
  84. return 0;
  85. }
Los codigos Deben ir en etiquetas GeSHi
>Engel Lex

Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines