0

How display diagonal of 2d array.. assume it is 3×3

14th Feb 2018, 5:47 AM
abhijeet
abhijeet - avatar
2 odpowiedzi
+ 5
size=3 //Left to right diagonal for(x=0;x<size;x++){ cout>>arr[x][x] } //Right to left diagonal for(x=0;x<size;x++){ cout>>arr[size-x-1][x] }
14th Feb 2018, 6:23 AM
Louis
Louis - avatar
0
Use a for loop to loop 3 indexes then access array[i][i] This will go diagonally through
14th Feb 2018, 9:23 AM
Joseph