c++ - store array in vectors and sort the elements -


I have a large number of numbers in a number of three,

is there a way to store them The method is to sort the number of a vector in the form of a unit and for printing such that the combination on the first number is sorted, if it does, then duplicate, then sort them further on the basis of the second number is done.

  • 234 123 465
  • 234 123 465
  • 567 890 123

    More For expected output:

    • 234 123 465
    • 234 123 678
    • 234 567 234
    • 567 890 123 li>

      You want basically two digit integers here, and then you want With custom comparator you can use std :: sort on it.

        bool vector_cmp (const vector  & amp; v1; Const vector & lt; int & gt; and v2) {for (vector & lt; int & gt; :: size_type i = 0; i & lt; v1.size (); ++ i) {if (v1.at (i) & lt; v2.at (i)) true return; And if (v2.at (i)   

      You can just type the previous line like this:

        std :: sort (int2dVector.begin (), int2dVector.end ());   

      Already exit to compare the vectors.

      operations , & lt; = And & gt; = Algorithm behaves like Lexifographical_Comparate, which is the sequence of elements in the operator & lt; Reflexively, stop at the first mismatch

      Disclaimer: This is not completely unwanted and only proof of concept code.

  • Comments

    Popular posts from this blog

    Verilog Error: output or inout port "Q" must be connected to a structural net expression -

    jasper reports - How to center align barcode using jasperreports and barcode4j -

    c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -