Advertisement
Guest User

Untitled

a guest
May 27th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. using namespace std;
  6. int main()
  7. {
  8.     float juego;
  9.    
  10.    
  11.    
  12.     cout<<" [1] Juego de Parejas :<"<<endl;
  13.     cout<<" [2] Ahorcado x3"<<endl;
  14.     cout<<" [3] Preguntas :D"<<endl;
  15.     cout<<" [4] Matematicas :3"<<endl;
  16.     cout<<" "<<endl;
  17.    
  18.     cout<<"             Elige el juego";
  19.     cin>>juego;
  20.     if (juego=1)
  21.     {
  22.    
  23.     int x1=-1, y1=-1, x2=-1, y2=-1, adivina[4][4];
  24.     char tablero[4][4], sw=0;
  25.     int i, j, c=0, k=1,ac=0, in=8, n1, n2, u1, u2;
  26.     tablero[0][0]='@';
  27.     tablero[0][1]='*';
  28.     tablero[0][2]='+';
  29.     tablero[0][3]='@';
  30.     tablero[1][0]='$';
  31.     tablero[1][1]='~';
  32.     tablero[1][2]='#';
  33.     tablero[1][3]='%';
  34.     tablero[2][0]='+';
  35.     tablero[2][1]='&';
  36.     tablero[2][2]='$';
  37.     tablero[2][3]='~';
  38.     tablero[3][0]='&';
  39.     tablero[3][1]='#';
  40.     tablero[3][2]='%';
  41.     tablero[3][3]='*';
  42.         for(i=0; i<4; i++)
  43.     {
  44.         for(j=0; j<4; j++)
  45.         {
  46.             adivina[i][j]=k;
  47.             k=k+1;
  48.                        
  49.         }
  50.     }
  51.     do
  52.     { system("cls");
  53.     c++;
  54.     for(i=0; i<4; i++)
  55.     {
  56.         cout<<endl<<endl;
  57.         for(j=0; j<4; j++)
  58.         {
  59.             if((x1==i&&y1==j)||(x2==i&&y2==j)||adivina[i][j]==0)cout<<tablero[i][j]<<"\t";
  60.             else
  61.             cout<<adivina[i][j]<<"\t";
  62.            
  63.         }
  64.     }
  65.    
  66.     cout<<endl<<endl;
  67.     cout<<"ACIERTOS= "<<ac<<endl<<endl;
  68.     system("pause");
  69.     cout<<endl<<"digite numero uno: ";
  70.     cin>>n1;
  71.     cout<<"digite numero dos: ";
  72.     cin>>n2;
  73.  
  74.    
  75.     if (n1=n2)
  76.     {cout<<"Son el mismo numero campeon, perdiste :3"<<endl;}
  77.    
  78.    
  79.    
  80.     for(i=0; i<4; i++)
  81.     {
  82.         for(j=0; j<4; j++)
  83.         {
  84.             if(adivina[i][j]==n1)
  85.             {
  86.                 x1=i;
  87.                 y1=j;
  88.             }
  89.             if(adivina[i][j]==n2)
  90.             {
  91.                 x2=i;          
  92.                 y2=j;
  93.             }
  94.         }
  95.     }
  96.     if(tablero[x1][y1]==tablero[x2][y2])
  97.     {
  98.         ac=ac+1;
  99.         adivina[x1][y1]=0;
  100.         adivina[x2][y2]=0;
  101.     }
  102.    
  103.     if(ac==8||c>=in) sw=1;
  104.     }while(sw==0);
  105.     if(ac==8)
  106.     cout<<"felicidades, pasaste al siguiente juego :3"<<endl;
  107.     else
  108.     cout<<"su numero de intentos termino "<<endl;
  109. }
  110.  
  111.  
  112. if (juego=2)
  113. {char palabra[50]=("carloscortez"), rep[100], temp [100];
  114. int longitud = 0, i, j=0, inicial=0, acierto=0, temporal=0, oport=6;
  115. bool repetido=false, ganar=false;
  116.  
  117. class Juego{
  118. private:
  119. char word;
  120.  
  121. public:
  122.  
  123. void Ahorcado(){
  124.   do{
  125.    temporal=0;
  126.    if(inicial==0){
  127.      for(i=0;i<strlen(palabra);i++){
  128.        if(palabra[i] == ' '){
  129.          temp[i] = ' ';
  130.          longitud++;
  131.        }
  132.        else{
  133.         temp[i] = '_';
  134.         longitud++;
  135.        }
  136.       }
  137.      }
  138.  
  139.    inicial = 1;
  140.    temp[longitud] = '\0';
  141.    for(i=0;i<strlen(rep);i++){
  142.     if(rep[i] == word){
  143.      repetido = true;
  144.      break;
  145.     }
  146.     else{
  147.      repetido = false;
  148.     }
  149.    }
  150.  
  151.    if(repetido == false){
  152.     for(i=0;i<strlen(palabra);i++){
  153.      if(palabra[i] == word){
  154.       temp[i] = word;
  155.       acierto++;
  156.       temporal = 1;
  157.       }
  158.      }
  159.     }
  160.  
  161.     if(repetido == false){
  162.      if(temporal == 0){
  163.       oport = oport - 1;
  164.      }
  165.     }
  166.     else{
  167.      printf("Esa letra ya fue digitada");
  168.      printf("\n\n");
  169.     }
  170.  
  171.     printf("\n");
  172.  
  173.     for(i=0;i<strlen(temp);i++){
  174.      printf(" %c ", temp[i]);
  175.     }
  176.  
  177.     printf("\n");
  178.  
  179.     if(strcmp(palabra,temp) == 0){
  180.      ganar = true;
  181.      break;
  182.     }
  183.  
  184.     printf("\n");
  185.  
  186.     printf("Letras acertadas: %d",acierto);
  187.     printf("\n");
  188.     printf("Oportunidades restantes: %d",oport);
  189.     printf("\n");
  190.     rep[j] = word;
  191.     j++;
  192.     printf("Digita una letra para adivinar la palabra:  ");
  193.     scanf("\n%c",&word);
  194.   }while(oport != 0);
  195.  }
  196. };
  197.  
  198. class Imprimir{
  199.  private:
  200.        string mensaje;
  201.  public:
  202.        void setmensaje(string a){
  203.         mensaje = a;
  204.        }
  205.        string getmensaje(){
  206.         return mensaje;
  207.        }
  208. };
  209.  
  210. int main()
  211. {
  212.     system("CLS");
  213.     rep[0] = ' ';
  214.     rep[1] = '\0';
  215.  
  216.     Juego Victima;
  217.     Imprimir mostrar;
  218.  
  219.     Victima.Ahorcado();
  220.  
  221.     if(ganar){
  222.      printf("\n\n");
  223.      mostrar.setmensaje("Adivinaste la palabra ;3");
  224.      cout<<mostrar.getmensaje();
  225.     }
  226.     else{
  227.      printf("\n\n");
  228.      mostrar.setmensaje("Perdiste?? :< pero puedes volver a intentarlo ");
  229.      cout<<mostrar.getmensaje();
  230.     }
  231.  
  232.     printf("\n\n");
  233.     system("PAUSE");
  234.     return 0;
  235. }
  236. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement