I am trying to use sort defined in algorithm in c++. I want to use it in vector string ( vector<string> vec) can we use it i vector string.
here is my code
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<string> vec;
vector<string> ::iterator it;
string s;
char b[5];
char a[5] = {'t','a','n','k','a'};
int l=strlen(a);
s = a;
vec.push_back(b);
for(int k=0;k<3;k++){
for(int i=0;i<5;i++){
if(i==0)
b[i] = a[4];
else
b[i] = a[i-1];
}
cout<<endl;
cout<<a;
for(int j=0;j<5;j++)
a[j] = b[j];
for(int j=0;j<5;j++)
s[j] = b[j];
vec.push_back(s);
}
vec.sort(vec.begin(),vec.end());
for(it = vec.begin();it!=vec.end();it++)
cout<<*it<<endl;
cout<<s<<endl;
return 0;
}
i wanted to generate different combination of 'tanka'