Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int v[400], val, x, n;
- int main()
- {
- int ok,i,aux;
- cout<<"n: "; cin>>n;
- for(int i=1; i<=n; i++) cin>>v[i];
- do
- {
- ok=1;
- for(i=1; i<=n-1; i++)
- if(v[i]>v[i+1])
- {
- ok=0;
- aux=v[i];
- v[i]=v[i+1];
- v[i+1]=aux;
- }
- }
- while(ok!=1);
- for(int i=1; i<=n; i++) cout<<v[i]<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment