What kind of sorting algorithm is this?
What is the name of the following simple sorting algorithm?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int a[7]={9,3,6,1,8,2,4};
//Sorting
for(int i=0; i<7; i++)
{
for(int j=i+1; j<7; j++)
{
if(a[j]<a[i])
{
swap(a[i],a[j]);
}
}
}
for(int k=0; k<7; k++)
cout<<a[k]<<" ";
return 0;
}
|
Topic archived. No new replies allowed.