reversing the rows of 2-d matrix in c++ | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
0

reversing the rows of 2-d matrix in c++

Given a n*m matrix, print the rows in reverse order. Do this for every row.

6th Apr 2020, 7:38 PM
Shivendra
Shivendra - avatar
1 Antwort
+ 1
#include<iostream> using namespace std; void reversePrint(int **arr,int n,int m) { int arr1[n][m]; for(int i=0;i<n;i++) { for(int j=m-1,k=0;j>=0,k<m;j--,k++) { arr1[i][k]=arr[i][j]; } } for(int i=0;i<n;i++) { for(int j=0;j<m;j++) cout<<arr1[i][j]<<" "; cout<<"\n"; } }
6th Apr 2020, 7:47 PM
Shivendra
Shivendra - avatar