Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int main()
- {
- int i,j,n, newn, A[100], aux;
- cin>>n;
- for (i=1; i<=n; i++)
- cin>>A[i];
- for (j=2; j<=n; j++)
- {
- for (i=n; i>=j; i--)
- if (A[i-1] > A[i])
- {
- aux = A[i-1];
- A[i-1] = A[i];
- A[i] = aux;
- }
- }
- for (i=1; i<=n; i++)
- cout<<A[i]<<" ";
- getch();
- }
Add Comment
Please, Sign In to add comment