https://pastein.ru/t/3K

  скопируйте уникальную ссылку для отправки


#include <iostream>
#include <sstream>
#include <vector>

using namespace std;

int main()
{
	setlocale(LC_ALL, "Russian");

	string input = "test lox loshka kapusta monitor sobaka koshka nudes";

	vector<string> words;
	stringstream x;
	x << input;

	while (!x.eof()) {
		string substring;
		x >> substring;
		words.push_back(substring);
	}

	cout << "Введите искомый символ: ";
	char find_this;
	cin >> find_this;
	vector<int> word_output = {-1};
	int char_output = 5112018;
	int count = 0;
	for (string n : words)
	{
		for (int i = 0; i <= n.length(); i++)
		{
			if (n[i] == find_this)
			{
				if (i <= char_output)
				{
					if (i < char_output)
					{
						word_output.clear();
					}
					word_output.push_back(count);
					char_output = i;
				}
			}
		}
		count++;
	}
	for (int n : word_output)
	{
		cout << "\nНомер слова: " << n << " Слово: " << words.at(n) << " Символ: " << find_this;
	}
}