fork download
  1. #include <iostream>
  2. using namespace std;
  3. #include <bits/stdc++.h>
  4. int main() {
  5. // your code goes here
  6. int n;
  7. cin>>n;
  8. int arr[n];
  9. int i=0;
  10. while(i<n)
  11. {
  12. cin>>arr[i];
  13. i++;
  14. }
  15.  
  16.  
  17. int count=0;
  18.  
  19. for(int i=0;i<n;i++)
  20. {
  21. for(int j=i+1;j<n;j++)
  22. {
  23. for(int k=j+1;k<n;k++)
  24. {
  25. for(int l=k+1;l<n;l++)
  26. {
  27. if(arr[i]+arr[j]+arr[k]+arr[l]==0)
  28. count++;
  29. }
  30. }
  31. }
  32. }
  33. cout<<count;
  34.  
  35. return 0;
  36. }
Success #stdin #stdout 0s 5284KB
stdin
7
1 2 3 4 -1 -2 -2
stdout
3