Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 01_03_Task3_Code.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <iostream> //for std::cout
- #include <string>
- #include <sstream>
- #include <iomanip>
- #include <vector>
- #include <iterator> //for std::ostream_iterator
- #include <algorithm> //for std::copy
- #include <utility> //pair<vey, value>
- #include <set>
- #include <unordered_set>
- using namespace std;
- void PrintV(vector<int> v)
- {
- std::copy(v.begin(), v.end(), ostream_iterator<int>(cout, ", "));
- }
- int main()
- {
- cin.sync_with_stdio(false);
- cout.sync_with_stdio(false);
- string line;
- getline(cin, line);
- unordered_set<int> setSeparators;
- int token;
- istringstream iss(line);
- while (iss >> token)
- {
- setSeparators.insert(token);
- }
- //CHECK:
- //cout << "DELIMITERS: " ;
- //PrintV(data_V_separators);
- //cout << endl;
- string text;
- getline(cin, text);
- int number;
- /*iss.str("");
- iss.clear();
- iss(text);*/
- istringstream iss2(text);
- vector<int> dataAllNumbers;
- while (iss2 >> number)
- {
- dataAllNumbers.push_back(number);
- }
- vector < vector<int> > dataV_AllPartsOf_V_numbers;
- vector<int> v;
- for (int i = 0; i < dataAllNumbers.size(); i++)
- {
- if (find(setSeparators.begin(), setSeparators.end(), dataAllNumbers[i]) == setSeparators.end())
- {
- v.push_back(dataAllNumbers[i]);
- if (i == dataAllNumbers.size() - 1)
- {
- if (!v.empty())
- {
- dataV_AllPartsOf_V_numbers.push_back(v);
- }
- }
- }
- else
- {
- if (!v.empty())
- {
- dataV_AllPartsOf_V_numbers.push_back(v);
- }
- v.clear();
- }
- }
- //CHECK:
- /*for (auto ve : dataV_AllPartsOf_V_numbers)
- {
- cout << "--------------------------------" << endl;
- PrintV(ve);
- cout << endl;
- }*/
- ostringstream output;
- int numToFind;
- cin >> numToFind;
- while (numToFind != 0)
- {
- int cnt = 0;
- for (auto vec : dataV_AllPartsOf_V_numbers)
- {
- //auto it = find(vec.begin(), vec.end(), numToFind);
- if (find(vec.begin(), vec.end(), numToFind) != vec.end())
- {
- cnt++;
- }
- }
- output << cnt << endl;
- cin >> numToFind;
- }
- cout << output.str() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement