// Jouanisson Florent // 27/05/18 // Version 1 #include #include #include int carte_joueur; int carte_ordi; int point_joueur; int point_ordi; int i; int def_carte_joueur (int carte_joueur){ carte_joueur = rand()%(13-1)+1; printf("carte = %i\n", carte_joueur); return carte_joueur; } int def_carte_ordi (int carte_ordi){ carte_ordi = rand()%(13-1)+1; return carte_ordi; } void affichage (int carte_joueur, int carte_ordi){ if (carte_joueur == 0){ printf("erreur"); } if (carte_ordi == 0){ printf("erreur"); } if (carte_joueur >0 && carte_joueur < 11){ printf("le joueur a tiré un %i\n", carte_joueur); } if (carte_joueur == 11){ printf("le joueur a tiré un valet"); } if (carte_joueur == 12){ printf("le joueur a tiré une dame"); } if (carte_joueur == 13){ printf("le joueur a tiré un roi"); } if (carte_ordi >0 && carte_ordi < 11){ printf("l'ordi a tiré un %i\n", carte_ordi); } if (carte_ordi == 11){ printf("l'ordi a tiré un valet"); } if (carte_ordi == 12){ printf("l'ordi a tiré une dame"); } if (carte_ordi == 13){ printf("l'ordi a tiré un roi"); } } int calcul ( int carte_joueur, int carte_ordi, int point_joueur, int point_ordi){ if (carte_joueur == 1){ if (carte_ordi == 1){ carte_joueur = rand()%(13-1)+1; carte_ordi = rand()%(13-1)+1; affichage(carte_joueur, carte_ordi); return calcul(carte_joueur, carte_ordi, point_joueur, point_ordi); } if (carte_ordi >= 2 && carte_joueur <= 13){ printf("le joueur gagne la manche"); point_joueur = point_joueur+1; return point_joueur; } } if (carte_joueur >= 2 && carte_joueur <= 13){ if (carte_ordi == 1){ printf("l'ordi gagne la manche"); point_ordi = point_ordi+1; return point_ordi; } if (carte_ordi >= 2 && carte_ordi <= 13){ if (carte_ordi > carte_joueur){ printf("l'ordi gagne la manche"); point_ordi = point_ordi+1; return point_ordi; } if (carte_ordi < carte_joueur){ printf("le joueur gagne la manche"); point_joueur = point_joueur+1; return point_joueur; } if (carte_ordi == carte_joueur){ carte_joueur = rand()%(13-1)+1; carte_ordi = rand()%(13-1)+1; affichage(carte_joueur, carte_ordi); return calcul(carte_joueur, carte_ordi, point_joueur, point_ordi); } } } return 0; } int main (){ while (i < 5){ def_carte_joueur(carte_joueur); def_carte_ordi(carte_ordi); affichage(carte_joueur, carte_ordi); getchar(); calcul(carte_joueur, carte_ordi, point_joueur, point_ordi); getchar(); i = i+1; } return 0; }