gabbbri_ella

carta_forbice_sasso

Nov 15th, 2019
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.67 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4.  
  5. #define SL 256
  6.  
  7. void main(void)
  8.  
  9.    {
  10.  
  11.       int variabile_giocatore,variabile_computer,i;
  12.       char variabile[SL];
  13.  
  14.       printf("Giochiamo. Digita:\n0 per CARTA\n1 per FORBICI\n2 per SASSO.\n");
  15.       for(i=0;i!=1;i++)
  16.         {
  17.             scanf("%s",variabile);
  18.             variabile_giocatore=atoi(variabile);
  19.             if (variabile_giocatore>=3)
  20.                {
  21.                   printf("ti piace vincere facile?! Riscrivi:\n");
  22.                   i--;
  23.                }
  24.         }
  25.      
  26.    start:
  27.       printf("Hai inserito questo?\n%d\ndammi conferma con S,s oppure digita N,n\n",variabile_giocatore);
  28.       scanf("%s",variabile);
  29.       switch (variabile[0])
  30.          {
  31.              case 'S' :
  32.                   printf("Apposto!\n");
  33.              case 's' :
  34.                   printf("Apposto!\n");
  35.                   break;
  36.              case 'N' :
  37.                   printf("MA SERIO?!\n");
  38.              case 'n' :
  39.                   printf("MA SERIO?!\n");
  40.              default: goto start;
  41.          }
  42.      
  43.        srand(time(NULL));
  44.        variabile_computer=(rand()/((RAND_MAX)/3));
  45.        //printf("var_computer:%d\n",variabile_computer);
  46.        
  47.        if (variabile_computer==variabile_giocatore)
  48.              printf("PAREGGIO!\n");
  49.        if ((variabile_computer==2) && (variabile_giocatore==0))
  50.           printf("HAI VINTO!");
  51.        else
  52.           {
  53.              if ((variabile_computer>variabile_giocatore) || ((variabile_computer==0) && (variabile_giocatore==2)))
  54.                 printf("HAI PERSO!\n");
  55.              else printf("HAI VINTO!\n");
  56.           }
  57.          
  58.  
  59.    }
Add Comment
Please, Sign In to add comment