Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <utility>
- using namespace std;
- int n;
- int A[21];
- void sortt()
- {
- int br=n-1;
- while (br>0)
- {
- if (br==n-1)
- {
- for (int i=0;i<n;i++) cout<<A[i]<<" ";
- cout<<endl;
- }
- for (int i=0;i<br;i++)
- {
- for (int j=i+1;j<br+1;j++)
- {
- if (A[i]>A[j])
- {
- int prenos=A[i];
- A[i]=A[j];
- A[j]=prenos;
- i++;
- for (int k=0;k<n;k++) cout<<A[k]<<" ";
- cout<<endl;
- }
- else i++;
- }
- }
- br--;
- }
- }
- int main()
- {
- cin>>n;
- for (int i=0;i<n;i++) cin>>A[i];
- sortt();
- return 0;
- }
Add Comment
Please, Sign In to add comment