Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Sorting A String Vector
7Priest7
post May 24 2007, 04:24 PM
Post #1


Newbie [ Level 1 ]
Group Icon

Group: Members
Posts: 3
Joined: 3-May 07
Member No.: 21,775



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. smile.gif

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[i].swap(Names[min]);
}
count=0;
cout << "\nAfter\n\n";
while(count<=2)
{
cout<<Names[count]<<'\n';
count++;
}
return 0;
}
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Array Sorting(21)
  2. Sorting A List(14)
  3. Question: Vector Based Animation?(4)
  4. Vector Sigs(18)
  5. Sorting In Treeview(2)
  6. VBScript: Help, Looping Through Registry Keys(1)
  7. Using Leading Zeros And Sorting Data(2)
  8. 10 Step Tutorial To Create Shiny Ball Vector Art(0)
  9. Bearded Man(6)
  10. Face Of A Friend(45)
  11. Ant And Larvae(6)
  12. "Orphan Work" And "Designing"(5)
  13. "Command Prompt"(5)
  14. Geese Formation(9)
  15. Story Teller(10)
  1. Sorting(0)
  2. Php String To Int Typecasting(6)
  3. How To Remove Query String Using Regular Expressions(4)
  4. Help Spliting A String Into 3 Variables In C++(2)
  5. City By The Night Vector Wallpaper(7)
  6. City By Night Vector Tutorial(0)
  7. Php Any Variable In String.(1)
  8. Check For Occurence Of Substring In String(3)
  9. Hearts Vector Wallpaper(0)
  10. Vector Linux(5)
  11. Strange Ascii Code 22 Character Detected In Connection String(9)
  12. String Theory(9)
  13. String Library Functions(4)


 



- Lo-Fi Version Time is now: 11th October 2008 - 01:03 PM