How to print only one option in terms of multiple case solutions.can you modify this code.
#include
#include
#include<bits/stdc++.h>
using namespace std;
int main(){
int t,n,d,sum,arr[1000],e;
cin>>t;
while(t–){
cin>>n;
for(int i=0;i<n;i++){
cin>>arr[i];
}
cin>>d;
sort(arr,arr+n);
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
sum=arr[i]+arr[j];
if(sum==d){
cout<<"Deepak should buy roses whose prices are “<<arr[i]<<” and "<<arr[j];
}
}
}
}
}
Pair of roses question
this is not correct because If there are multiple solutions print the solution that minimizes the difference between the prices i and j.
Correct Approach
Can you explain where have you used the case of single option in the code and also how can I modify my code by involving the case of printing single option only.