0 Replies - 603 Views - Last Post: 15 March 2009 - 10:26 AM Rate Topic: -----

#1 sonzthegreat  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 04-August 08

Selection sort rule of pass need help

Posted 15 March 2009 - 10:26 AM

HELLO to all ^_^ i had a problem about how to output the rule of passing in selection sort, for example the input numbers are:
18 20 17 40 22 27 30 the output should be like this:
17 20 18 40 22 27 30
17 18 20 40 22 27 30
17 18 20 22 40 27 30
17 18 20 22 27 40 30
17 18 20 22 27 30 40

here's my code::

#include<stdio.h>
#include<conio.h>

main()
{
int num[7];
int t,a,j;
clrscr();
{printf("Enter 7 number:\n\n");}
for (a=0;a<=6;a++)
{scanf("%d",&num[a]); }
for(a=0;a<=6;a++)
   		{ for(j=a+1;j<=6;j++)
   	 	   if(num[a]>num[j])
				 { t=num[a];
					  num[a]=num[j];
		 				num[j]=t; }
		}
		for(a=0;a<=6;a++)
		{ printf("%d ", num[a]); }
getch();
}


Is This A Good Question/Topic? 0
  • +

Page 1 of 1