#include
using namespace std;
#include <stdio.h>
int main() {
int n;
int arr[n];
cin>>n;
for (int i =0;i<n;i++){
cin>>arr[n];
}
int sum;
cin>>sum;
for(int j=0;j<n;j++){
for(int k=j+1;k<n;k++){
if((arr[j]+arr[k])==sum){
cout<<arr[j]<<" and "<<arr[k];
cout<<endl;
}
}
}
return 0;
}
this is my code not able to understand it is not giving write ans for tests cases
Can't identify the problem
In the question it is mentioned that you have to print the pairs in sorted order. So try with the 2 pointer approach after sorting the array. There must be a hint video on this question. Please refer that.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.