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