Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Messge Count word to repead.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include <iostream>
- #include <string>
- #include <sstream>
- #include <map>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- string input, word;
- int occurrenceCount, index, N, count;
- map<string, int>Centence;
- vector<pair<int, int>>Ocurence;
- vector<string>Result;
- while (word != ".")
- {
- cin >> word;
- Centence[word]++;
- }
- cin >> N; //number of queri
- for (int i = 0; i < N; i++)
- {
- cin >> occurrenceCount >> index;
- Ocurence.push_back(make_pair(occurrenceCount, index));
- }
- for (auto it = Ocurence.begin(); it != Ocurence.end(); it++)
- {
- for (auto itC = Centence.begin(); itC != Centence.end(); itC++)
- {
- if ((it->first) == (itC->second))
- {
- Result.push_back(itC->first);
- }
- }
- //vtora proverka po index
- // sort(Result.begin(), Result.end());
- if (Result.empty())
- {
- cout << "." << endl;
- break;
- }
- else if ((it->second) > Result.size())
- {
- break;
- }
- for (int k = 0; k < Result.size(); k++)
- {
- if ((it->second) == k)
- {
- cout << Result[k] << endl;
- break;
- }
- }
- Result.clear();
- }
- }
- // Run program: Ctrl + F5 or Debug > Start Without Debugging menu
- // Debug program: F5 or Debug > Start Debugging menu
- // Tips for Getting Started:
- // 1. Use the Solution Explorer window to add/manage files
- // 2. Use the Team Explorer window to connect to source control
- // 3. Use the Output window to see build output and other messages
- // 4. Use the Error List window to view errors
- // 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
- // 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Advertisement
Add Comment
Please, Sign In to add comment