Skip to content

Instantly share code, notes, and snippets.

@HSley13
Created September 5, 2023 11:01
Show Gist options
  • Save HSley13/aec433fada84171f3d52182341f28da6 to your computer and use it in GitHub Desktop.
Save HSley13/aec433fada84171f3d52182341f28da6 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
int table[10]; int a, b, i, size=10;
for(i=0; i<size; i++) table[i]= rand();
cout<<" This is the orinal Array \n";
for(i=0; i<size; i++)
{
cout<<table[i]<<endl;
}
cout<<endl;
for(a=0; a<size; a++)
{
for(b=size-1; b>=a; b--)
{
if (table[b-1]>table[b])
{
i=table[b-1];
table[b-1]=table[b];
table[b]=i;
}
}
}
cout<<" The New Array is presented thus "<<endl;
for(i=0; i<size; i++)
{
cout<<table[i]<<endl;
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment