Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.17 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. void afficheBarres (int r)
  5. {
  6.     int i;
  7.     for (i=1;i<=r;i++)
  8.     {
  9.         printf("|");
  10.     }
  11.     printf("\n");
  12. }
  13.  
  14.  
  15.  
  16. void jouers (int r)
  17. {
  18.     int possible;
  19.     int jouer1;
  20.     int jouer2;
  21.  
  22.  
  23.         do
  24. {
  25.  
  26.         if(r==1)
  27.         {
  28.             possible=1;
  29.         }
  30.         else
  31.         {possible=(int)r/2;
  32.         }
  33.         printf("Vous pouvez retirer %d allumetes au maximum\n",possible);
  34.         printf("jouer1=");
  35.         scanf("%d",&jouer1);
  36.         r=r-jouer1;
  37.         afficheBarres(r);
  38.         if(r==1)
  39.         {
  40.             possible=1;
  41.         }
  42.         else
  43.         {possible=(int)r/2;
  44.         }
  45.         printf("Vous pouvez retirer %d allumetes au maximum\n",possible);
  46.         printf("Jouer2=");
  47.         scanf("%d",&jouer2);
  48.         r=r-jouer2;
  49.         afficheBarres(r);
  50.  
  51.     }while(r>1);
  52.  
  53.      if (r==1 && jouer1==1)
  54.  
  55.         {printf("Jouer1 a gagne!");
  56.         }
  57.  
  58.         if(r==1 && jouer2==1)
  59.         {
  60.         printf("Jouer2 a gagne!");
  61.         }
  62.  
  63. }
  64.  
  65. int main()
  66. {
  67.     printf("nb d'allumetes:");
  68.     int n;
  69.     scanf("%d",&n);
  70.     afficheBarres(n);
  71.     jouers(n);
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement