Inversion of Array

Run Settings
LanguageC++
Language Version
Run Command
#include <iostream> using namespace std; int count(int A[], int n){ int c=0; for(int i =0 ; i<n-1; i++){ for(int j=i; j<n; j++){ if(A[j]<A[i]) c++; } } return c; } int main() { int n; cin>>n; int A[n]; for(int i=0; i<n; i++) { cin>>A[i]; } cout<<count(A,n); }
Editor Settings
Theme
Key bindings
Full width
Lines