include iostream include map include vector include algorithm using na

 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
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int lines;
int counter = 1;
while (cin>>lines && lines)
{
vector<char> has_value;
has_value.push_back('a');
while(lines--)
{
char var1, var2;
cin >> var1;
cin >> var2 >> var2;
if (find(has_value.begin(),has_value.end(),var2)
!=has_value.end())
{
if (find(has_value.begin(),has_value.end(),var1)
==has_value.end()) has_value.push_back(var1);
}
else
{
vector<char>::iterator iter;
iter = find(has_value.begin(),has_value.end(),var1);
if (iter!=has_value.end())
{
has_value.erase(iter);
}
}
}
printf("Program #%d\n",counter);
if (has_value.size())
{
sort(has_value.begin(),has_value.end());
for (int i=0;i<has_value.size()-1;i++)
printf("%c ",has_value[i]);
printf("%c\n\n",has_value.back());
}
else printf("none\n\n");
counter++;
}
}