-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCount_arrayPairs.cpp
More file actions
44 lines (34 loc) · 1.36 KB
/
Count_arrayPairs.cpp
File metadata and controls
44 lines (34 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// c++ code to count the total pairs in an array of integers satisfying the given condition in the if block of the code
// running for various test cases inputted by the user
// condition to be fulfilled is ==> i*a[i] > j*a[j] .../
#include<iostream>
using namespace std ;
int main()
{
int t ;
cin>>t;
int counter=0;
while(t--)
{
int n ;
cin>>n ;
int a[n];
counter=0;
for(int m=0 ; m<=n-1;m++)
{
cin>>a[m];
}
for(int i=0 ;i<=n-1;i++)
{
for(int j=i ; j<=n-1 ; j++)
{
if(i*a[i] > j*a[j])
{
counter++;
}
}
}
cout<<counter<<endl;
}
return 0 ;
}