Hustlingbeast_Anish

Anish1

Feb 16th, 2022
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1.  
  2. #include<bits/stdc++.h>
  3. #include <algorithm>
  4. #define lli long long int
  5. #define li long int
  6. #define mod 1000000007
  7. #define ld long double
  8. #define pb push_back
  9. using namespace std;
  10.  
  11. int main(){
  12. ios_base::sync_with_stdio(false);
  13. cin.tie(NULL);
  14.  
  15. int n;
  16. cin>>n;
  17.  
  18.  
  19. int arr[n];
  20. for (int i = 0; i < n; i++)
  21. {
  22. cin>>arr[i];
  23. }
  24. int k;
  25. cin>>k;
  26.  
  27.  
  28. vector<pair<int,int> > vec;
  29. for (int i = 0; i < n; i++)
  30. {
  31. for (int j = 0; j < n && j!=i; j++)
  32. {
  33. if(arr[i]+arr[j]==k){
  34. vec.push_back(make_pair(arr[i],arr[j]));
  35. }
  36. }
  37.  
  38. }
  39.  
  40.  
  41. for (int i = 0; i < vec.size(); i++)
  42. {
  43. cout<<vec[i].first<<" "<<vec[i].second<<endl;
  44. }
  45.  
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment