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
|
#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iterator>
using namespace std;
int positions[5]={1,2,3,4,5};
string colors[5]={"blue","yellow","red","green","white"};
string nationalities[5]={"Dane","Swede","German","Englishman","Norwegian"};
string drinks[5]={"water","bier","coffee","tea","milk"};
string smokes[5]={"Pall Mall","Prince","Blue Maters","Dunhill","Blend"};
string pets[5]={"Fish","Cats","Horses","Dogs","Birds"};
struct PlayerInfo
{
int position;
string color;
string nationality;
string favorite_drink;
string favorite_smoke;
string pet;
};
int main ()
{
srand(time(NULL)); /*Randomize the program*/
/*Shuffle the arrays*/
random_shuffle(positions[0],positions[5]);
random_shuffle(colors[0],colors[5]);
random_shuffle(nationalities[0],nationalities[5]);
random_shuffle(drinks[0],drinks[5]);
random_shuffle(smokes[0],smokes[5]);
random_shuffle(pets[0],pets[5]);
/*Assign the arrays to each house*/
PlayerInfo Player[5];
for (int i=0;i<5;i++)
{
Player[i].position=positions[i];
Player[i].color=colors[i];
Player[i].nationality=nationalities[i];
Player[i].favorite_drink=drinks[i];
Player[i].favorite_smoke=smokes[i];
}
/*Tell the user the combinations created*/
for (int i=0;i<5;i++)
{
cout<<"The house nr. "<<Player[i].position<<" is "<<Player[i].color<<" and is inhabited by a "<<Player[i].nationality<<
" who drinks "<<Player[i].favorite_drink<<" and smokes "<<Player[i].favorite_smoke<<" and enjoys the company of "<<Player[i].pet<<"."<<endl<<endl;
}
}
|