Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n,i,j,k,a[1000],temp;
- cin>>n;
- for(i=1; i<=n; i++)
- {
- cin>>a[i];
- }
- for(i=1; i<=n; i++)
- {
- for(j=1; j<n; j++)
- {
- if(a[j] > a[j+1])
- {
- temp = a[j];
- a[j] = a[j+1];
- a[j+1] = temp;
- }
- }
- }
- for(i=1; i<=n; i++)
- {
- cout<<a[i]<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment