Advertisement
jasonpogi1669

Count the number of pairs where i < j using C++

Jul 10th, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     int a[n];
  9.     for (int i = 0; i < n; i++) {
  10.         cin >> a[i];
  11.     }
  12.     cout << (n * (n - 1)) / 2 << '\n';
  13.     return 0;
  14. }
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement