fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int arr[]={1,2,3,4,5,6};
  7.  
  8. int n= sizeof(arr)/sizeof(arr[0]);
  9.  
  10. int odd_count=0;
  11. int even_count=0;
  12.  
  13. for(int i=0;i<n-2;i++){
  14. for(int j=i+1;j<n-1;j++){
  15. for(int k=j+1;k<n;k++){
  16. int triplet_sum=arr[i]+arr[j]+arr[k];
  17. if(triplet_sum%2==0){
  18. even_count++;
  19. }else{
  20. odd_count++;
  21. }
  22. }
  23. }
  24. }
  25. cout<<even_count<<" "<<odd_count;
  26. return 0;
  27. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
10 10