Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void afficheBarres (int r)
- {
- int i;
- for (i=1;i<=r;i++)
- {
- printf("|");
- }
- printf("\n");
- }
- void jouers (int r)
- {
- int possible;
- int jouer1;
- int jouer2;
- do
- {
- if(r==1)
- {
- possible=1;
- }
- else
- {possible=(int)r/2;
- }
- printf("Vous pouvez retirer %d allumetes au maximum\n",possible);
- printf("jouer1=");
- scanf("%d",&jouer1);
- r=r-jouer1;
- afficheBarres(r);
- if(r==1)
- {
- possible=1;
- }
- else
- {possible=(int)r/2;
- }
- printf("Vous pouvez retirer %d allumetes au maximum\n",possible);
- printf("Jouer2=");
- scanf("%d",&jouer2);
- r=r-jouer2;
- afficheBarres(r);
- }while(r>1);
- if (r==1 && jouer1==1)
- {printf("Jouer1 a gagne!");
- }
- if(r==1 && jouer2==1)
- {
- printf("Jouer2 a gagne!");
- }
- }
- int main()
- {
- printf("nb d'allumetes:");
- int n;
- scanf("%d",&n);
- afficheBarres(n);
- jouers(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement