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
|
#include<iostream>
#include<conio.h>
#include<string>
#include<cstdlib>
#include<ctime>
#include <time.h>
#include <stdio.h>
using namespace std;
int main ()
{
char numb1array[3][3] = { '1','2','3','4','5','6','7','8','9',};
for(int i = 0; i < 3; ++i)
{
for(int j = 0; j < 3; ++j)
{
cout << numb1array[i][j];
}
cout << endl;
}
const int ARRAY_SIZE = 9;
srand(time(0));
string numbers[ARRAY_SIZE] = {"1","2","3","4","5","6","7","8","9"};
for (int i=0; i< ARRAY_SIZE; i++) {
int index = rand() % ARRAY_SIZE;
string temp = numbers[i];
numbers[i] = numbers [index];
numbers[index] = temp;
}
for (int i=0; i< ARRAY_SIZE; i++) {
cout << numbers[i] << endl;
}
_getch();
}
|