Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Author: Kanan Asgarli
- https://www.e-olymp.com/az/problems/2663
- */
- #include <iostream>
- using namespace std;
- int main()
- {
- //bubble sort
- int n, say = 0;
- cin>>n;
- int a[n];
- for(int i = 0; i < n; i++)
- cin>>a[i];
- for(int i = 0; i < n; i++){
- for(int j = 0; j < n-1; j++){
- if(a[j] > a[j+1]){
- swap(a[j], a[j+1]);
- say++;
- }
- }
- }
- cout<<say<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment