Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void BubbleSort(int A[],int n)
- {
- int temp;
- for (int i=1;i<=n;i++)
- {
- for (int j=1;j<n-i;j++)
- {
- if (A[j]>A[j+1])
- {
- temp=A[j];
- A[j]=A[j+1];
- A[j+1]=temp;
- }
- }
- }
- }
- int main()
- {
- int n;
- cin>>n;
- int * A=new int [n+1];
- for (int i=1;i<=n;i++)
- {
- cin>>A[i];
- }
- BubbleSort(A,n);
- for (int i=1;i<=n;i++)
- {
- cout<<A[i]<<" ";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement