SlideShare una empresa de Scribd logo
1 de 6
#include<iostream.h>
#include<ctype.h>
#include<time.h>
#include<windows.h>
#include<math.h>
#include<conio.h>
#include <cstdlib>
//######################################################################

int e,i,j,q,m,n,x=0,fila1,columna1,fila2,columna2,puntaje=0;
char rand_1[16]={'1','2','3','4','5','1','6','7','8','2','6','7','8','3','4','5'};//variables usadas
struct caractmen
{
char ch[5][5];
};
char vjugar;
caractmen char_1[2];
void juegoterminado();
void primervalor();
void segundovalor();
void delay(long seconds) ;
void gotoxy(int x, int y);
void valorpuntaje();
void nuevalinea(int y);
void output_1();
void num_1();
void num_2();
void main_1();
void slide_horz_right( int x ,int y , char ch[]);
void tiempo(unsigned int mseconds);
/***************************************************************************************
********/
int main()// generara
{


 srand((unsigned)time(0));
 using std::random_shuffle;
 random_shuffle(rand_1,rand_1+16);
    for( m=1 ; m<5 ; m++)
 {
  for ( n=1 ; n<5 ; n++)
  {
   do
   {
    char_1[1].ch[m][n]=*(rand_1+x);
    x++;
    break;
   }while(x<16);
  }
 }
char_1[0].ch[0][0]=' ';
 for ( int u=1 ; u<5 ; u++)
 {
  char_1[0].ch[0][u]=48+u;
  char_1[0].ch[u][0]=48+u;
for(int y=1 ; y<5 ; y++)
 {
  char_1[0].ch[u][y]='*';
 }
}



{
     system("color f3");
 cout<< "       t"<<"          1 2 3 4"<<endl<<endl<<endl;
 for( i=1 ; i<5 ; i++)
 {
  cout<<"       ttt";
  for ( j=0 ; j<5 ; j++)
  {
   cout<<char_1[0].ch[i][j]<<" ";
  }
  cout<<endl<<endl<<endl;
 }
}
nuevalinea(3);
main_1();
nuevalinea(4);
}
/***************************************************************************************
********/
void num_1()
{
primervalor();
system("cls");
output_1();
valorpuntaje();
nuevalinea(1);
num_2();
}
/***************************************************************************************
********/
void num_2()
{
segundovalor();
system("cls");
if(fila1==fila2&&columna1==columna2)
{
 char_1[0].ch[fila1][columna1]='*';
 output_1();
 valorpuntaje();
 nuevalinea(3);
    cout<<"ErrornnINGRESASTE POSICIONES IGUALES!!!!nnCASTIGO DE CUATRO
PUNTOS"<<endl<<endl<<endl;
 delay(3000);
 system("cls");
 output_1();
 valorpuntaje();
 nuevalinea(3);
 num_1();
system("cls");
 puntaje-=4;
}
}
/***************************************************************************************
********/
void primervalor()        //ingresar el primer punto
{
printf("Ingrese las cordenadas del punto que desea ver n");
cout<<"FILA NUMERO... ";
cin>>fila1;
cout<<"COLUMNA NUMERO... ";
cin>>columna1;
if(columna1>4||fila1>4)
{
 printf("nCORDENADAS INCORRECTASnnINGRESE VALORES ENTRE 1 y 4nn");
   primervalor();
}
cout<<endl<<endl;
if(char_1[0].ch[fila1][columna1]==' ')
{
 system("cls");
 output_1();
 printf("ErrornnESTE PUNTO YA ESTA DESIFRADO INGRESA NUEVAS CORDENADAS
nn");
   primervalor();
}
cout<<endl<<endl;
char_1[0].ch[fila1][columna1]=char_1[1].ch[fila1][columna1];
}
/***************************************************************************************
********/
void segundovalor()         //ingresar el segundo punto
{
 nuevalinea(2);
printf("Ingrese las cordenadas del punto que desea ver nn");
cout<<"FILA NUMERO... ";
cin>>fila2;
cout<<"COLUMNA NUMERO... ";
cin>>columna2;
if(columna2>4||fila2>4)
{
 printf("nCORDENADAS INCORRECTASnnINGRESE VALORES ENTRE 1 y 4nn");
   segundovalor();
}
cout<<endl<<endl;
if(char_1[0].ch[fila2][columna2]==' ')
{
 system("cls");
 output_1();
 printf("ErrornnESTE PUNTO YA ESTA DESIFRADO INGRESA NUEVAS CORDENADASnn");
   segundovalor();
}
cout<<endl<<endl;
char_1[0].ch[fila2][columna2]=char_1[1].ch[fila2][columna2];
}
/***************************************************************************************
********/
void output_1()          //mostrar la pantalla principal del juego
{
 for( e=0 ; e<5 ; e++)
{
 cout<<"       ttt";
 for(q=0 ; q<5 ; q++)
 {
   cout<<char_1[0].ch[e][q]<<" ";
 }
 cout<<endl<<endl<<endl;
}
}
/***************************************************************************************
********/
void main_1()
{
 valorpuntaje();
 gotoxy(1,20);
 num_1();
output_1();
valorpuntaje();
if(char_1[1].ch[fila1][columna1]==char_1[1].ch[fila2][columna2])
{
 gotoxy(1,20);
   cout<<"ENCONTRASTE UNA PAREJA,,BIEN¡¡¡nn TIENES DIEZ PUNTOS¡¡"<<endl;
   char_1[0].ch[fila1][columna1]=' ';
   char_1[0].ch[fila2][columna2]=' ';
   puntaje+=10;
}
else
{
 gotoxy(1,20);
 printf("FALLASTE, INTENTA OTRA VEZnnCASTIGO DE DOS PUNTOS");
 nuevalinea(5);
 puntaje-=2;
}
if(char_1[1].ch[fila1][columna1]!=char_1[1].ch[fila2][columna2])
{
 char_1[0].ch[fila1][columna1]='*','*';
 char_1[0].ch[fila2][columna2]='*','*';
}
tiempo(1600);
system("cls");
output_1();
valorpuntaje();
for (i=1 ; i<2 ; i++)
{
 for ( j=1 ; j<2 ; j++)
 {
  if (char_1[0].ch[i][j]==' '&&char_1[0].ch[i][j+1]==' '&&char_1[0].ch[i][j+2]=='
'&&char_1[0].ch[i][j+3]==' '&&char_1[0].ch[i+1][j]==' '&&char_1[0].ch[i+1][j+1]=='
'&&char_1[0].ch[i+1][j+2]==' '&&char_1[0].ch[i+1][j+3]==' '&&char_1[0].ch[i+2][j]=='
'&&char_1[0].ch[i+2][j+1]==' '&&char_1[0].ch[i+2][j+2]==' '&&char_1[0].ch[i+2][j+3]=='
'&&char_1[0].ch[i+3][j]==' '&&char_1[0].ch[i+3][j+1]==' '&&char_1[0].ch[i+3][j+2]=='
'&&char_1[0].ch[i+3][j+3]==' ')
  {
  cout<<"nnGanaste!! tu puntaje es... "<<puntaje<<endl<<endl;
  cout<<"QUIERES INICIAR UN NUEVO JUEGO?(s/n)";
  cin>>vjugar;
  vjugar=tolower(vjugar);
  while(isdigit(vjugar))
  {
   cout<<"ESCOGE UNA OPCION";
   cin>>vjugar;
  }
  if (vjugar=='s')
  {
   puntaje=0;
   x=0;
   system("cls");
   main();
  }
  if (vjugar=='n')
  {
   cout<<"JUEGO TERMINADO";
   exit(0);
  }
  else
  {
   exit(0);
  }
  }
 }
}
main_1();
}
/***************************************************************************************
********/
void nuevalinea(int y)        //hace el numero de nuevas lineas
{
 for (e=0 ; e<y ; e++)
  cout<<endl;
}
/***************************************************************************************
********/
void delay(long seconds)         //Esta funcion es para hacer una pantalla de tiempo
{
 clock_t time1 = clock(); // usar hora del sistema
    clock_t time2 = time1 + seconds;
   while(time1 < time2)
    time1 = clock();
   return;
}
/***************************************************************************************
********/
void valorpuntaje(){          //con esto actualizamos puntaje
 gotoxy(64,17);
 cout<<"Puntaje = "<<puntaje<<endl;
}
/***************************************************************************************
********/
void tiempo(unsigned int mseconds)
{
  clock_t goal = mseconds + clock();
  while (goal > clock());
}
/***************************************************************************************
********/

/***************************************************************************************
********/
void slide_horz_right( int x ,int y , char ch[]) //Esta funcion es para mover el texto en la
pantalla
{
 for ( int i=1 ; i<x ; i++)
 {
  gotoxy(i,y);
  {
   cout<<ch<<endl;
  cout<<"         ";
  delay(25);
  }
  gotoxy(64,47);
 }
}
/***************************************************************************************
********/

Más contenido relacionado

La actualidad más candente (16)

Problema c++
Problema c++Problema c++
Problema c++
 
Include
IncludeInclude
Include
 
Programa de Cola Estática
Programa de Cola EstáticaPrograma de Cola Estática
Programa de Cola Estática
 
Practica de programacion 21 28
Practica de programacion 21 28Practica de programacion 21 28
Practica de programacion 21 28
 
Rubenmajano
RubenmajanoRubenmajano
Rubenmajano
 
Programa de Pila Estática
Programa de Pila EstáticaPrograma de Pila Estática
Programa de Pila Estática
 
Ejercicios de programacion concurrente
Ejercicios de programacion concurrenteEjercicios de programacion concurrente
Ejercicios de programacion concurrente
 
Funcione
FuncioneFuncione
Funcione
 
Do while
Do whileDo while
Do while
 
Colas apuntadores dinámicos
Colas apuntadores dinámicosColas apuntadores dinámicos
Colas apuntadores dinámicos
 
Pilas con apuntadores dinamicos
Pilas con apuntadores dinamicosPilas con apuntadores dinamicos
Pilas con apuntadores dinamicos
 
Ejercicios en Netbeans
Ejercicios en NetbeansEjercicios en Netbeans
Ejercicios en Netbeans
 
Practicas de programacion 11 20
Practicas de programacion 11 20Practicas de programacion 11 20
Practicas de programacion 11 20
 
Lenguaje de raptor, c# y java
Lenguaje de raptor, c# y javaLenguaje de raptor, c# y java
Lenguaje de raptor, c# y java
 
Hack (Lenguaje de Programacion)
Hack (Lenguaje de Programacion)Hack (Lenguaje de Programacion)
Hack (Lenguaje de Programacion)
 
NOTACIÓN POSTFIJA E INFIJA - JAVA
NOTACIÓN POSTFIJA E INFIJA - JAVANOTACIÓN POSTFIJA E INFIJA - JAVA
NOTACIÓN POSTFIJA E INFIJA - JAVA
 

Similar a JUEGO CONCENTRECE PARA ENTORNO DEV C++ (20)

Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Codigos de programas
Codigos de programasCodigos de programas
Codigos de programas
 
Ahorcado
AhorcadoAhorcado
Ahorcado
 
programa de matematicas en lenguaje c
programa de matematicas en lenguaje c programa de matematicas en lenguaje c
programa de matematicas en lenguaje c
 
Hechos en clase
Hechos en claseHechos en clase
Hechos en clase
 
Informe tecnico
Informe tecnicoInforme tecnico
Informe tecnico
 
08 strings o cadenas
08 strings o cadenas08 strings o cadenas
08 strings o cadenas
 
1... conversor de bases
1... conversor de bases1... conversor de bases
1... conversor de bases
 
Jorge informe tecnico
Jorge informe tecnicoJorge informe tecnico
Jorge informe tecnico
 
Juego Bingo - JAVA
Juego Bingo - JAVAJuego Bingo - JAVA
Juego Bingo - JAVA
 
Union y concatenacion
Union y concatenacionUnion y concatenacion
Union y concatenacion
 
PROBLEMAS DE POGRAMACION 1
PROBLEMAS DE POGRAMACION 1PROBLEMAS DE POGRAMACION 1
PROBLEMAS DE POGRAMACION 1
 
Vector
Vector Vector
Vector
 
Pseudocodigo
PseudocodigoPseudocodigo
Pseudocodigo
 
Pila
PilaPila
Pila
 
Ejercicios de programacion en c++
Ejercicios de programacion en c++Ejercicios de programacion en c++
Ejercicios de programacion en c++
 
Cpp
CppCpp
Cpp
 
Cpp
CppCpp
Cpp
 
Ejemplos c++
Ejemplos c++Ejemplos c++
Ejemplos c++
 
Copilacion de ejercicios en java
Copilacion de ejercicios en javaCopilacion de ejercicios en java
Copilacion de ejercicios en java
 

JUEGO CONCENTRECE PARA ENTORNO DEV C++

  • 1. #include<iostream.h> #include<ctype.h> #include<time.h> #include<windows.h> #include<math.h> #include<conio.h> #include <cstdlib> //###################################################################### int e,i,j,q,m,n,x=0,fila1,columna1,fila2,columna2,puntaje=0; char rand_1[16]={'1','2','3','4','5','1','6','7','8','2','6','7','8','3','4','5'};//variables usadas struct caractmen { char ch[5][5]; }; char vjugar; caractmen char_1[2]; void juegoterminado(); void primervalor(); void segundovalor(); void delay(long seconds) ; void gotoxy(int x, int y); void valorpuntaje(); void nuevalinea(int y); void output_1(); void num_1(); void num_2(); void main_1(); void slide_horz_right( int x ,int y , char ch[]); void tiempo(unsigned int mseconds); /*************************************************************************************** ********/ int main()// generara { srand((unsigned)time(0)); using std::random_shuffle; random_shuffle(rand_1,rand_1+16); for( m=1 ; m<5 ; m++) { for ( n=1 ; n<5 ; n++) { do { char_1[1].ch[m][n]=*(rand_1+x); x++; break; }while(x<16); } } char_1[0].ch[0][0]=' '; for ( int u=1 ; u<5 ; u++) { char_1[0].ch[0][u]=48+u; char_1[0].ch[u][0]=48+u;
  • 2. for(int y=1 ; y<5 ; y++) { char_1[0].ch[u][y]='*'; } } { system("color f3"); cout<< " t"<<" 1 2 3 4"<<endl<<endl<<endl; for( i=1 ; i<5 ; i++) { cout<<" ttt"; for ( j=0 ; j<5 ; j++) { cout<<char_1[0].ch[i][j]<<" "; } cout<<endl<<endl<<endl; } } nuevalinea(3); main_1(); nuevalinea(4); } /*************************************************************************************** ********/ void num_1() { primervalor(); system("cls"); output_1(); valorpuntaje(); nuevalinea(1); num_2(); } /*************************************************************************************** ********/ void num_2() { segundovalor(); system("cls"); if(fila1==fila2&&columna1==columna2) { char_1[0].ch[fila1][columna1]='*'; output_1(); valorpuntaje(); nuevalinea(3); cout<<"ErrornnINGRESASTE POSICIONES IGUALES!!!!nnCASTIGO DE CUATRO PUNTOS"<<endl<<endl<<endl; delay(3000); system("cls"); output_1(); valorpuntaje(); nuevalinea(3); num_1();
  • 3. system("cls"); puntaje-=4; } } /*************************************************************************************** ********/ void primervalor() //ingresar el primer punto { printf("Ingrese las cordenadas del punto que desea ver n"); cout<<"FILA NUMERO... "; cin>>fila1; cout<<"COLUMNA NUMERO... "; cin>>columna1; if(columna1>4||fila1>4) { printf("nCORDENADAS INCORRECTASnnINGRESE VALORES ENTRE 1 y 4nn"); primervalor(); } cout<<endl<<endl; if(char_1[0].ch[fila1][columna1]==' ') { system("cls"); output_1(); printf("ErrornnESTE PUNTO YA ESTA DESIFRADO INGRESA NUEVAS CORDENADAS nn"); primervalor(); } cout<<endl<<endl; char_1[0].ch[fila1][columna1]=char_1[1].ch[fila1][columna1]; } /*************************************************************************************** ********/ void segundovalor() //ingresar el segundo punto { nuevalinea(2); printf("Ingrese las cordenadas del punto que desea ver nn"); cout<<"FILA NUMERO... "; cin>>fila2; cout<<"COLUMNA NUMERO... "; cin>>columna2; if(columna2>4||fila2>4) { printf("nCORDENADAS INCORRECTASnnINGRESE VALORES ENTRE 1 y 4nn"); segundovalor(); } cout<<endl<<endl; if(char_1[0].ch[fila2][columna2]==' ') { system("cls"); output_1(); printf("ErrornnESTE PUNTO YA ESTA DESIFRADO INGRESA NUEVAS CORDENADASnn"); segundovalor(); } cout<<endl<<endl; char_1[0].ch[fila2][columna2]=char_1[1].ch[fila2][columna2]; }
  • 4. /*************************************************************************************** ********/ void output_1() //mostrar la pantalla principal del juego { for( e=0 ; e<5 ; e++) { cout<<" ttt"; for(q=0 ; q<5 ; q++) { cout<<char_1[0].ch[e][q]<<" "; } cout<<endl<<endl<<endl; } } /*************************************************************************************** ********/ void main_1() { valorpuntaje(); gotoxy(1,20); num_1(); output_1(); valorpuntaje(); if(char_1[1].ch[fila1][columna1]==char_1[1].ch[fila2][columna2]) { gotoxy(1,20); cout<<"ENCONTRASTE UNA PAREJA,,BIEN¡¡¡nn TIENES DIEZ PUNTOS¡¡"<<endl; char_1[0].ch[fila1][columna1]=' '; char_1[0].ch[fila2][columna2]=' '; puntaje+=10; } else { gotoxy(1,20); printf("FALLASTE, INTENTA OTRA VEZnnCASTIGO DE DOS PUNTOS"); nuevalinea(5); puntaje-=2; } if(char_1[1].ch[fila1][columna1]!=char_1[1].ch[fila2][columna2]) { char_1[0].ch[fila1][columna1]='*','*'; char_1[0].ch[fila2][columna2]='*','*'; } tiempo(1600); system("cls"); output_1(); valorpuntaje(); for (i=1 ; i<2 ; i++) { for ( j=1 ; j<2 ; j++) { if (char_1[0].ch[i][j]==' '&&char_1[0].ch[i][j+1]==' '&&char_1[0].ch[i][j+2]==' '&&char_1[0].ch[i][j+3]==' '&&char_1[0].ch[i+1][j]==' '&&char_1[0].ch[i+1][j+1]==' '&&char_1[0].ch[i+1][j+2]==' '&&char_1[0].ch[i+1][j+3]==' '&&char_1[0].ch[i+2][j]==' '&&char_1[0].ch[i+2][j+1]==' '&&char_1[0].ch[i+2][j+2]==' '&&char_1[0].ch[i+2][j+3]=='
  • 5. '&&char_1[0].ch[i+3][j]==' '&&char_1[0].ch[i+3][j+1]==' '&&char_1[0].ch[i+3][j+2]==' '&&char_1[0].ch[i+3][j+3]==' ') { cout<<"nnGanaste!! tu puntaje es... "<<puntaje<<endl<<endl; cout<<"QUIERES INICIAR UN NUEVO JUEGO?(s/n)"; cin>>vjugar; vjugar=tolower(vjugar); while(isdigit(vjugar)) { cout<<"ESCOGE UNA OPCION"; cin>>vjugar; } if (vjugar=='s') { puntaje=0; x=0; system("cls"); main(); } if (vjugar=='n') { cout<<"JUEGO TERMINADO"; exit(0); } else { exit(0); } } } } main_1(); } /*************************************************************************************** ********/ void nuevalinea(int y) //hace el numero de nuevas lineas { for (e=0 ; e<y ; e++) cout<<endl; } /*************************************************************************************** ********/ void delay(long seconds) //Esta funcion es para hacer una pantalla de tiempo { clock_t time1 = clock(); // usar hora del sistema clock_t time2 = time1 + seconds; while(time1 < time2) time1 = clock(); return; } /*************************************************************************************** ********/ void valorpuntaje(){ //con esto actualizamos puntaje gotoxy(64,17); cout<<"Puntaje = "<<puntaje<<endl; }
  • 6. /*************************************************************************************** ********/ void tiempo(unsigned int mseconds) { clock_t goal = mseconds + clock(); while (goal > clock()); } /*************************************************************************************** ********/ /*************************************************************************************** ********/ void slide_horz_right( int x ,int y , char ch[]) //Esta funcion es para mover el texto en la pantalla { for ( int i=1 ; i<x ; i++) { gotoxy(i,y); { cout<<ch<<endl; cout<<" "; delay(25); } gotoxy(64,47); } } /*************************************************************************************** ********/