Selection Sort Program in C++ With Source Code
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int current,j,n;
current=0;
int list[5]={7,5,6,9,8};
int temp=0;
n=5;
while(current<n)
{
j=current+1;
while(j<n)
{
if(list[current]>=list[j])
{
temp=list[current];
list[current]=list[j];
list[j]=temp;
}
j++;
}
current++;
}
printf("Ascending order:\n");
for(current=0;current<n;current++)
{
printf("%d\n",list[current]);
}
getch();
}
#include<conio.h>
void main()
{
clrscr();
int current,j,n;
current=0;
int list[5]={7,5,6,9,8};
int temp=0;
n=5;
while(current<n)
{
j=current+1;
while(j<n)
{
if(list[current]>=list[j])
{
temp=list[current];
list[current]=list[j];
list[j]=temp;
}
j++;
}
current++;
}
printf("Ascending order:\n");
for(current=0;current<n;current++)
{
printf("%d\n",list[current]);
}
getch();
}
Selection Sort Program in C++ With Source Code
Reviewed by Unknown
on
5:48:00 PM
Rating:
No comments: