Hi Guys,
i was reading a book about C++ sorting and come up with the first type of sortting knowing as "Bubble-Sort" belwo is the main code for, you can run it and see how the arry will be ordred.
int main()
{
int a[]={5,4,2,8,1,9,2,10,3,7,6};
int i,j,temp;
for(i=0;i<11;i++)
cout<<a[i]<<" ";
cout<<endl;
for(i=0;i<10;i++)
for(j=0;j<(10-i);j++)
if(a[j]>a[j+1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
for(i=0;i<11;i++)
cout<<a[i]<<" ";
cout<<endl;
getchar();
return 1;
}
Howover, the book talked brefly about something called Selection -sort, can i one give me a example with code?
:lol: