#include
#include
using namespace std;
bool compare(int arr,int n)
{
return arr<n;
}
int main()
{
int n,i,j;
cin>>n;
int arr[1000];
for(int i=0;i<n;i++)
{
cin>>arr[i];
}
sort(arr,arr+n,compare);
int ts;
cin>>ts;
i=0;
j=sizeof(arr)/sizeof(int)-1;
while(i<j)
{
long int cs=arr[i]+arr[j];
if(cs<ts)
{
i++;
}
else if(cs==ts)
{
cout<<arr[i]<<“and”<<arr[j]<<endl;
i++;
j–;
}
else if(cs>ts)
{
j–;
}
}
return 0;
}
Not able to find the error for the testcases
Check the pattern of output in the sample case…it must match exactly with your output…include the spaces if there in the sample output
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.
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.