Question
In c++ language, I need to change the integer array to char array or string array with the code below: A B C 101 102
In c++ language, I need to change the integer array to char array or string array with the code below:
A B C
101 102 103
104 105 106
X X X
to random shuffle
A B C
X 102 103
104 X 106
X 105 101
using namespace std;
void print(int** a){ cout<<" A B C"< for(int i = 0;i<3;i++){ cout<
int main() { int** a = new int*[3]; for(int i = 0; i < 3; ++i){ a[i] = new int[3]; } int num = 101; for(int i = 0;i<3;i++){ for(int j = 0;j<3;j++){ a[i][j] = num; num++; } } print(a); for(int i=3-1;i>=0;i--)
{
for(int j=3-1;j>=0;j--)
{
int k=rand()%3;
int l=rand()%3;
int t=a[i][j];
a[i][j]=a[l][k];
a[l][k]=t;
cout<
}
cout<<" ";
}
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started