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