1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#include "../std_lib_facilities.h"
int main()
{
srand(3);
int seed = 0;
while (cout << "Entre un chiffre" )
{
vector<int>nombres(4);
nombres[0] = randint(10);
nombres[1] = randint(10);
nombres[2] = randint(10);
nombres[3] = randint(10);
int rouge = 0;
int blanc = 0;
int r1 = 0;
int r2 = 0;
int r3 = 0;
int r4 = 0;
while (cin>>r1>>r2>>r3>>r4)
{
vector<int>reponse;
reponse.push_back(r1);
reponse.push_back(r2);
reponse.push_back(r3);
reponse.push_back(r4);
for (int i = 0; i < 4; ++i)
{
if (reponse[i] == ordi[i]) ++rouge;
else
for (int x = 0; x < 4; ++x)
if (reponse [i] == ordi[x]) ++blanc;
}
if (rouge == 4){
cout << "Bravo ! Try Again !\n";
cout << "Entrez un chiffre ";
cin >> seed;
srand(seed);
}
else
cout << "rouges : " << rouge << " blancs : " << blanc << endl;
rouge = 0;
blanc = 0;
}
}
return 0;
} |
Partager