fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. // your code goes here
  6. int b[]={5,6,4,3,6};
  7. int n=sizeof(b)/sizeof(b[0]);
  8. int k=3;
  9. int count=0;
  10. for(int i=0;i<n;i++){
  11. for(int j=i+1;j<n;j++){
  12. if(b[i]-b[j]==k){
  13. count++;
  14.  
  15. }
  16. }
  17. }
  18. cout<<count;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
1