Jump to content
xisto Community
Sign in to follow this  
7Priest7

Sorting A String Vector

Recommended Posts

I did this code for a reason...
It was a school project...

I could not find this info anywhere...
Maybe it will be use to some1 else. B)

		count++;
}
int i,j;
int min;

for(i=0;i< 3 - 1;i++)
{
min = i;

for (j = i + 1; j<3;j++)
{
if (Names[j] < Names[min]){min=j;}}
Names.swap(Names[min]);
}
count=0;
cout << "\nAfter\n\n";
while(count<=2)
{
cout<<Names[count]<<'\n';
count++;
}
return 0;
} linenums:0'>#include <iostream>#include <vector>#include <string>using namespace std;int main(){ int count=0; vector<string> Names(2); Names[0]="Alexa"; Names[1]="Alexc"; Names[2]="Alexb"; cout << "Before\n\n"; while(count<=2) { cout<<Names[count]<<'\n'; count++; } int i,j; int min; for(i=0;i< 3 - 1;i++) { min = i; for (j = i + 1; j<3;j++) { if (Names[j] < Names[min]){min=j;}} Names.swap(Names[min]); } count=0; cout << "\nAfter\n\n"; while(count<=2) { cout<<Names[count]<<'\n'; count++; } return 0;}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.