|
|
|
|
![]() ![]() |
May 24 2007, 04:24 PM
Post
#1
|
|
|
Newbie [ Level 1 ] 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. 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; } |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 11th October 2008 - 01:03 PM |