fekr o bekr
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main(){
char colors[4];
srand(time(0));
int random = (rand()%4)+1;
for(int i=0;i<4;i++){
random = (rand()%4)+1;
switch(random){
case 1:
colors[i] = 'r';
break;
case 2:
colors[i] = 'g';
break;
case 3:
colors[i] = 'b';
break;
case 4:
colors[i] = 'y';
break;
}
}
char inputColor[4];
cout << "Colors reserved!" << endl;
cout << endl << endl;
int Count = 0;
while(Count != 6)
{
Count++;
cout << "This try : " << Count << endl;
for(int i=0;i<4;i++){
cout << "Color " << i << ": ";
cin >> inputColor[i];
cout << endl;
}
for(int i=0;i<4;i++){
if(inputColor[i] == colors[i])
cout << "Black" << " ";
}
if(inputColor[0] == colors[1] ||
inputColor[0] == colors[2] ||
inputColor[0] == colors[3] ){
cout << "White" << " ";
}
if(inputColor[1] == colors[0] ||
inputColor[1] == colors[2] ||
inputColor[1] == colors[3]){
cout << "White" << " ";
}
if(inputColor[2] == colors[0] ||
inputColor[2] == colors[1] ||
inputColor[2] == colors[3]){
cout << "White" << " ";
}
if(inputColor[3] == colors[0] ||
inputColor[3] == colors[1] ||
inputColor[3] == colors[2])
{
cout << "White" << " ";
}
cout << endl << endl;
if(inputColor[0] == colors[0] &&
inputColor[1] == colors[1] &&
inputColor[2] == colors[2] &&
inputColor[3] == colors[3])
{
cout << "You win! Tries : " << Count << endl;
Count = 6;
}
else
{
cout << "Mistake!" << endl << endl;
}
}
if(Count == 6){
cout << "You lost!" << endl;
}
cin.get();
return 0;
}