I need help to solve all my problem Statement

Problem Statement

Pantelis has won a voucher C euros from a hypermarket. With this money Pantelis can buy any two items from a list L items, whose total value should be as much the value of the Gift Voucher. Which two objects can buy Pantelis from the list?

Input Format

Integer C (5 <= C <= 100000), the value of the Gift Voucher in euro.
Integer L (3 <= L <= 1000), the objects are listed.
A list of numbers L P (1 <= P <= 100000), the value of each object.
Output Format

For any event be shown in ascending order positions of the two objects in the list.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  #include<iostream>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <utility>
using namespace std;

int main (){
int a,b,c;

float p[100000];
int pos = 0;
int pos1;
int pos2;
int sum;

cin>>a;
cin>>b;
for (int i=0; i<=b; i++){
    cin>>p[i];
sort(p,p+b);
do{
    sum=(p[i]+p[i+1]);

}while(sum=a);

}
cout<<p[i]<<p[i+1];
return 0;
}


i write this but i don't know any more..
can you help me ?
You are inputting the numbers correctly and sorting the array, but the logic in lines 22-28 is wrong. For example, the loop at lines 22-25 will probably never exit because line 25 assigns the a to some (= operator) rather than comparing them (== operator). Also, i never changes in the loop, so it just keeps computing the same old sum value.

Try to describe the algorithm in words, then translate it into code.
am trying but i don't know how to check if two number are equal = with my begin number :( and after i must know the position but i don't know why can anyone help me ?
Topic archived. No new replies allowed.