mercredi 3 août 2016

C++ sorting in lexicographically order

here is my code :

 sort(S1.begin(), S1.begin()+4);
for ( int i = 0; i < S1.capacity(); i++ )
cout << S1[i]<<endl;

I am getting this : a aa aab ab b a aa aac ac c

but I should be getting this: "a", "aa", "aab", "aac", "ab", "ac", "b", "c"

what am I doing wrong ?

Aucun commentaire:

Enregistrer un commentaire