Answer to Question #288011 in C++ for Toto

Question #288011

Sort a c++ program one and two and three dimensional array in ascending and descending order

1
Expert's answer
2022-01-17T00:34:18-0500
#include<iostream>
#include<vector> 
#include<algorithm> 
using namespace std;


int main()
{
    vector< vector<int> > vect{{2, 5, 1},
                            {4, 6, 11},
                            {8, 2, 1}};
    int m = vect.size();


    int n = vect[0].size();


    for (int i=0; i<m; i++)
    {
        for (int j=0; j<n ;j++)
        cout << vect[i][j] << " ";
        cout << endl;
    }


    sort(vect[0].begin(), vect[0].end());


    for (int i=0; i<m; i++)
    {
        for (int j=0; j<n ;j++)
            cout << vect[i][j] << " ";
        cout << endl;
    }


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment