|
|
Sorting A String Vector | ||
Discussion by 7Priest7 with 0 Replies.
Last Update: May 24, 2007, 9:24 am | |||
![]() |
|
|
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.
#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;
}
It was a school project...
I could not find this info anywhere...
Maybe it will be use to some1 else.
CODE
#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;
}
Similar Topics:
10 Step Tutorial To Create Shiny Ba...
A week back or so, I happened to stumble across Inkscape (http://inkscape.org) and I was hooked. In a few days, I was able to create some things that were recognizable, and I created two clip arts at my blog as give aways:
[url="http://www.wisetome.com/splat/2006/12/09/free-clipart-chr ...more
Php String To Int Typecasting
City By Night Vector Tutorial
Did I Install A C Or A C++ Compiler ? A simple way to see the difference (6)
|
(1) Learning C++
|
HOME 





2. Vectors in Multiple Dimensions
Algorithms Lesson 2: Insertion Sort
36.Curso XHTML. Uso de Arrays en JavaScript

