Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // Counting inversions
- //
- // Created by Panagiotis Hadjicostas on 17/08/2019.
- // Copyright © 2019 Panagiotis Hadjicostas. All rights reserved.
- //
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cin>>n;
- int i,j,a[n];
- int counter=0;
- for(i=0;i<n;i++){
- cin>>a[i];
- if(i>0){
- for(j=0;j<i;j++){
- if(a[i]<a[j]){
- counter++;
- }
- }
- }
- }
- cout<<counter<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement