fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n,x ; cin>>n>>x;
  7. vector<int>arr(n);
  8. for(int i = 0 ; i<n;i++){
  9. cin>>arr[i];
  10. }
  11. for(int i =0;i<n;i++){
  12. for(int j = i+1;j<n;j++){
  13. if(arr[i]+arr[j]==x){
  14. cout<<"pair found"<<arr[i]<<" "<<arr[j]<<"\n";
  15. break;
  16. }
  17. }
  18. }
  19. // your code goes here
  20. return 0;
  21. }
Success #stdin #stdout 0.01s 5324KB
stdin
5 4 
1 2 4 3 2
stdout
pair found1 3
pair found2 2