Skip to content

Instantly share code, notes, and snippets.

@Michaelkodji
Last active October 6, 2020 22:50
Show Gist options
  • Save Michaelkodji/f07b95bdc2f973fceb6b8031f2c286a7 to your computer and use it in GitHub Desktop.
Save Michaelkodji/f07b95bdc2f973fceb6b8031f2c286a7 to your computer and use it in GitHub Desktop.
jeu du mastermind (simplifié)
#include <iostream>
using namespace std;
int compteur=4;int combinaison_cache[5]={1,2,3,4,5}; int combinaison_entre[5] , reponse=0;
int main()
{
cout<<"Bonjour et bienvenue dans le jeu MASTERMIND"<<endl;
do{
cout<<" Entrer votre combinaison "<<endl;
for(int i=0;i<=4;i++){
cin>>combinaison_entre[i];
}
int i=0;
int j=0;
reponse=0;
while(combinaison_cache[j] == combinaison_entre[i]){
j++;
i++;
reponse++;
}
cout<<endl<<reponse<<" numeros bien place"<<endl;
compteur--;
}while(compteur!=0 && reponse!=5);
if(reponse==5 || compteur!=0){
cout<<"Bravo vous avez gagn\202 en "<<compteur<<" essai"<<endl;
}else {
cout<<"Vous avez perdu la bonne combinaison était:"<<endl;
for(int i=0;i<=4;i++){
cout<<combinaison_cache[i];
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment