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
|
#include <string>
#include <ctime>
#include <cstdlib>
#include <iostream>
using namespace std;
void gridEasy(void);
void randomizeTheme(string theme[]);
int _tmain(int argc, _TCHAR* argv[])
{
string theme[16] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p" };
randomizeTheme(theme);
for (int i = 0; i < 16; i++)
{
cout << theme[i] << endl;
}
system("Pause");
return 0;
void randomizeTheme(string theme[])
{
int r;
srand(time(0));
for (int i = 0; i < 16; i++)
{
string temp;
r = rand() % 16;
temp = theme[i];
if (theme[i] != theme[r])
{
theme[i] = theme[r];
theme[r] = theme[i];
}
}
}
|