selection sort




//implementing selection sort
#include<iostream.h>
#include<conio.h>
void main()
{
int a[20],ptr,i,k,loc,min,temp;
clrscr();
cout<<"Enter the elements in array";
for(i=1;i<=10;i++)
{
cin>>a[i];
}
for(i=1;i<=10;i++)
{
min=a[i];
loc=i;
ptr=i+1;
while(ptr<=10)
{
if(min>a[ptr])
{
min=a[ptr];
loc=ptr;
}
ptr++;
}

temp=a[i];
a[i]=a[loc];
a[loc]=temp;
}
cout<<"Sorted array is\n";
for(i=1;i<=10;i++)
cout<<"\na["<<i<<"]="<<a[i];
getch();
}
********output**********












No comments:

Post a Comment

using avrdude with AVR studio(for windows 10 only)

Requirements 1. arduino-1.6.5-r2-windows.exe 2. as6installer-6.0.1843.exe When I try to configure avrdude in avr studio 6 then wina...