First of all, you should explain what your program does, as it is not clear...
Your program looks at a list of numbers (lst) and checks if any two neighbors add up to a certain value (x).
Here's a similar program in C++:
#include <iostream>
#include <vector>
int main()
{
std::cout << "The program asks for a sequence of integral numbers and checks if any two neighbours sum to a specific value." << std::endl;
std::cout << "What sum should we look for? : ";
int targetSum;
if (!(std::cin >> targetSum))
{
std::cerr << "Not a number." << std::endl;
return -1;
}
int number;
std::vector<int> numbers;
bool numberRead = true;
std::cout << "Please, enter the next element in the sequence (not a number to finish)." << std::endl;
do
{
std::cout << ": ";
if (std::cin >> number)
numbers.push_back(number);
else
numberRead = false;
} while (numberRead);
int matchCount = 0;
int lastIndex = numbers.size() - 1;
for (int i = 0; i < lastIndex; i++)
{
if (numbers[i] + numbers[i + 1] == targetSum)
matchCount++;
}
std::cout << "Number of pairs summing up to " << targetSum << ": " << matchCount << std::endl;
return 0;
}