I am trying to write a program to print a 2d array, swap certain elements, and print it in reverse This is the array:
int arr [3] [3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};.
I want to do this:
1 2 3 4 5 6 7 8 9
1 4 7 2 5 8 3 6 9
9 8 7 6 5 4 3 2 1
This is what i have but i am totally lost.
#include <iostream>
using namespace std;
int main() {
void printArray(int arr[][5]){
int a,b,c,d;
int temp=0;
for (a=0; c=3; a<=3; a++, c--){
for (b=0, d=4; b<=4; b++, d--){
}
//1
int arr [3] [3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
int x = 2, m = 4;
swap (x,m);
printarray(arr,3,3);
return 0;
}