Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /*
- * File: main.cpp
- * Author: maxim
- *
- * Created on May 31, 2016, 8:26 PM
- */
- #include <vector>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- bool cmp(vector<int> a, vector<int> b) {
- if(a.size() == b.size()) {
- return a < b;
- } else {
- return a.size() < b.size();
- }
- }
- int main(int argc, char** argv) {
- vector<int> a1{1};
- vector<int> a2{1, 2};
- vector<int> a3{1, 2, 3};
- vector<int> a4{2, 3};
- vector<int> a5{5, 6};
- vector<vector<int> > v{a1, a2, a3, a4, a5};
- sort(v.begin(), v.end(), cmp);
- for(int i = 0; i < 5; ++i) {
- for(int j = 0; j < v[i].size(); ++j) {
- cout << v[i][j] << ' ';
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment