12,500,937 members (49,633 online)
Rate this:
See more:
```#include<iostream.h>

(main) void
{
int i, j, first, temp;
int numLength = num.length( );
for (i= numLength - 1; i > 0; i--)
{
first = 0;
for (j=1; j<=i; j++)
{
if (num[j] < num[first])
first = j;
}
temp = num[first];
num[first] = num[i];
num[i] = temp;
}
return;
}```

Code block added, HTML encoded - OriginalGriff[/edit]
Posted 8-Jan-13 8:21am
Updated 8-Jan-13 9:37am
CPallini389.4K
v4
richcb 8-Jan-13 14:23pm

This is not a question. Elaborate on your issue and explain what you are trying to accomplish. Then, form a specific question on what you need help with.
OriginalGriff 8-Jan-13 14:23pm

This is not a good question - we cannot work out from that little what you are trying to do.
You seem to have forgotten to tell us what your problem is...
Use the "Improve question" widget to edit your question and provide better information.

i need slection sort example plz share who its work

Rate this:

## Solution 3

Your code won't compile, even on the ancient compiler you are using (why don't you use a more modern `C++` compiler?).

You probably mean:
```#include <iostream.h>

// the selection sort function
void sort(int num[], int numLength);

// usage sample
int main()
{
int v[] =  {0,7,-5, 10000, 45};
const int SIZE = sizeof(v)/sizeof(v[0]);
sort(v, SIZE);
for (int i=0; i<SIZE; i++)
cout << v[i] << " ";
cout << endl;
}
// sort implementation
void sort(int num[], int numLength)
{
int i, j, first, temp;
if ( numLength < 2) return;

for (i = numLength - 1; i > 1; i--)
{
first = 0;
for (j=1; j<=i; j++)
{
if (num[j] < num[first])
first = j;
}
temp = num[first];
num[first] = num[i];
num[i] = temp;
}
```
nv3 8-Jan-13 16:15pm

Hey, you are way too good to these guys who are trying to get their homework done :-)
CPallini 9-Jan-13 3:01am

:-)
Rate this:

## Solution 2

Looks like a homework to me. but google search would list your result.

Check here[^]
Rate this:

## Solution 1

This is not a question at all. The one thing I will say is, iostream.h is not C++. Just include iostream without the .h. Apart from that, this is a code dump. If you have a question, edit this post, and ask it. If not, it will be deleted.

Top Experts
Last 24hrsThis month
 OriginalGriff 228 David_Wimbley 205 Karthik Bangalore 105 Richard MacCutchan 85 Mehdi Gholam 50
 OriginalGriff 6,548 ppolymorphe 3,669 Maciej Los 3,283 David_Wimbley 2,647 Karthik Bangalore 2,569