Badyx

[C++] Juego piedra, papel o tijeras

May 29th, 2013
324
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.42 KB | None | 0 0
  1. /*
  2. [img]http://img39.imageshack.us/img39/7388/piedra1.bmp[/img]
  3. [img]http://img62.imageshack.us/img62/6571/piedra2.png[/img]
  4. [img]http://img441.imageshack.us/img441/2788/piedra3.png[/img]
  5. */
  6.  
  7. #include <stdio.h>
  8. #include <windows.h>
  9. #include <string.h>
  10.  
  11. int PuntosMaquina = 0;
  12. int PuntosJugador = 0;
  13. char Nombre[15];
  14.  
  15. void Jugar();
  16.  
  17. int main ()
  18. {
  19.     using namespace std;
  20.     printf ("*************************************************************\n");
  21.     printf ("**          Juego Piedra papel o tijeras By BadyX          **\n");
  22.     printf ("*************************************************************\n");
  23.     printf("\nIntroduce tu nombre:\n");
  24.     scanf("%s",&Nombre);
  25.     Jugar();
  26.     return 0;
  27. }
  28.  
  29. void Jugar()
  30. {
  31.     srand(GetTickCount());
  32.     int i;
  33.     char Eleccion[7];
  34.     char Respuesta;
  35.     do
  36.     {
  37.     system("cls");
  38.     printf( "[Resultado] Maquina %d %s %d.\n",PuntosMaquina, Nombre ,PuntosJugador);
  39.     printf("\nEscriba su eleccion:\nPiedra papel o tijeras\n");
  40.     gets(Eleccion);
  41.     if (strcmp(Eleccion,"piedra")== 0)
  42.     {
  43.     printf(" \nUsted escogio piedra:");
  44.     i = (rand()% 3) + 1;
  45.     if (i==1)
  46.     {
  47.     printf("\nEl ordenador escogio piedra y enpataron.");
  48.     }
  49.     if(i==2)
  50.     {
  51.     printf("\nEl ordenador escogio papel y te gano.");
  52.     PuntosMaquina ++;
  53.     }
  54.     if(i==3)
  55.     {
  56.     printf("\nEl ordenador escogio tijeras y ganaste.");
  57.     PuntosJugador ++;
  58.     }
  59.     }
  60.     if (strcmp(Eleccion,"tijeras")== 0)
  61.     {
  62.     printf("\nUsted escogio tijeras:");
  63.     i = (rand()% 3) + 1;
  64.     if (i==1)
  65.     {
  66.     printf("\nEl ordenador escogio piedra y perdiste");
  67.     PuntosMaquina ++;
  68.     }
  69.     if(i==2)
  70.     {
  71.     printf("\nEl ordenador escogio papel y le ganaste");
  72.     PuntosJugador ++;
  73.     }
  74.     if(i==3)
  75.     {
  76.     printf("\nEl ordenador escogio tijeras y empatasteis");
  77.     }
  78.     }
  79.     if (strcmp(Eleccion,"papel")== 0)
  80.     {
  81.     printf("\nUsted escogio papel:");
  82.     i = (rand()% 3) + 1;
  83.     if (i==1)
  84.     {
  85.     printf("\nEl ordenador escogio piedra y ganaste");
  86.     PuntosJugador ++;
  87.     }
  88.     if(i==2)
  89.     {
  90.     printf("\nEl ordenador escogio papel y empatasteis");
  91.     }
  92.     if(i==3)
  93.     {
  94.     printf("\nEl ordenador escogio tijeras y perdistes");
  95.     PuntosMaquina ++;
  96.     }
  97.     }
  98.     printf("\n\nQuiere seguir jugando?.(S/N)");
  99.     scanf("%c",&Respuesta);
  100.     setbuf ( stdin, NULL );
  101.     }
  102.     while ((Respuesta =='S') || (Respuesta =='s'));
  103.     getchar();
  104. }
Advertisement
Add Comment
Please, Sign In to add comment