This is my code. The only thing I’m unable to do is arrange the pairs in increasing order. I think it can be done using vectors, but that hasn’t been covered in the course yet. What else can I do?
#include
using namespace std;
int main()
{
int n;
cin>>n;
int arr[n];
for (int i=0; i<n; i++)
{
cin>> arr[i];
}
int key;
cin>>key;
for (int a=0; a<n; a++)
{
for (int b=a+1; b<n; b++)
{
int sum= arr[a] + arr[b];
if (sum==key)
{
cout << arr[a] << " and " << arr[b] << endl;
}
}
}
return 0;
}
