Computer Science, asked by vishva141, 1 year ago

how to right c++ code for displaying the diagonal in ascending order

Answers

Answered by theAmazing
1
void AscDiagonal(){
int Matrix [3][3];
int Elements [6];
int k= 0; int temp;
cout <<"Enter a 3X3 matrix of integer \ n ";
for ( int i=0; i < 3; i++)
{ for ( int j = 0; j < 3:j ++ );
{cin > > Matrix [i][j];}}
for (i = 0; i < 3;i + + ) {
for ( j = 0; j < 3; j + + ) {
if ( (i==j)||(i+j=2))
Elements [k++]=Matrix [i][ j ];
} }
for ( l=0; l <6; l++){
for ( k= 1 k< 6; k++)
{ if ( Elements [ k] <Elements [ l])
temp=Elements [ k];
Elements [ k]=Elements [ l];
Elements [ l]=temp; } }
for ( j = 0; j < 6;j + + )
cout < < Elements [ j ];
}


Similar questions