void createArray(int a, int b, int c, int d, int array[3][3]){
int state[3][3];
for(int x=0;x<3;x++){
for(int y=0;y<3;y++){
if(x == a && y == b){
state[x][y] = array[c][d];
}
else if(x == c && y == d){
state[x][y] = array[a][b];
}
else{
state[x][y] = array[x][y];
}
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
cout << state[i][j] << " ";
}
cout << endl;
}
}
I have basically got this function which clones the multidimensional array that is inputed but swaps the values of the two co-ordinates (a,b) and (c,d) around. This is then outputted out to the console.
However what I would really like is for this to be returned as a multidimensional array, but I don't think this can be done?
I have looked at vectors and pointers but don't really understand them and if I use them, I will then have to change all the previous code I have written.
returnactually? What's the actual inputs/outputs/errors?arrayis the input 2D array.stateis the 2D array he wants to return.