Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
#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;
}
 
[edit]Code block added, HTML encoded - OriginalGriff[/edit]
Posted 8-Jan-13 8:21am
Edited 8-Jan-13 9:37am
CPallini309.3K
v4
Comments
richcb at 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 at 8-Jan-13 14:23pm
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
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.
wazir ahmad at 8-Jan-13 14:35pm
   
i need slection sort example plz share who its work
Rate this: bad
good
Please Sign up or sign in to vote.

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;
  }
  
  Permalink  
Comments
nv3 at 8-Jan-13 16:15pm
   
Hey, you are way too good to these guys who are trying to get their homework done :-)
CPallini at 9-Jan-13 3:01am
   
:-)
Rate this: bad
good
Please Sign up or sign in to vote.

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Looks like a homework to me. but google search would list your result.
 
Check here[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 590
1 OriginalGriff 535
2 CPallini 285
3 Peter Leow 185
4 RyanDev 161
0 OriginalGriff 5,784
1 Sergey Alexandrovich Kryukov 4,838
2 Peter Leow 3,009
3 Maciej Los 2,894
4 DamithSL 2,465


Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100