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