blob: 7b6b1850947dccb4334d818d2ecc941beb0fa5c6 (
plain) (
blame)
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
int main() {
std::string str;
std::vector<std::pair<std::string, int>> myVector;
getline(std::cin, str);
std::stringstream ss;
ss << str;
std::string temp;
while (ss >> temp) {
std::string lowString = "";
bool is_exist = false;
for (size_t i = 0; i < temp.size(); i++)
{
lowString += tolower(temp[i]);
}
for (size_t i = 0; i < myVector.size(); i++)
{
if (myVector[i].first == lowString)
{
myVector[i].second++;
is_exist = !is_exist;
break;
}
}
if (is_exist == false)
{
myVector.push_back(std::make_pair(lowString, 1));
}
}
std::vector<std::string> outVector;
for (size_t i = 0; i < myVector.size(); i++)
{
if (myVector[i].second % 2 == 1)
{
outVector.push_back(myVector[i].first);
}
}
for (size_t i = 0; i < outVector.size() - 1; i++)
{
std::cout << outVector[i] << ", ";
}
std::cout << outVector[outVector.size() - 1] << std::endl;
return 0;
}
|