Posted by MindBreaker at 8:54 AM
Read our previous post
Object
1-
Bubble
sort in assending order.
Source code
#include <iostream>
using namespace std;
void
main()
{
int
sort[7]={1,2,3,4,5,643,56};
int i, j,
temp;
for(i =
0; i < 6; i ++)
{
for(j
= i + 1; j < 7; j++)
{
if(sort[i]
> sort [j])
{
temp = sort [i];
sort[i] = sort [j];
sort[j] = temp;
}
}
}
for(i =
0; i < 7; i++)
{
cout << endl;
cout << sort [i] <<
endl;
}
}
Output
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.