-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathques2.cpp
More file actions
45 lines (43 loc) · 869 Bytes
/
ques2.cpp
File metadata and controls
45 lines (43 loc) · 869 Bytes
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
#include <iostream>
#include<map>
#include<vector>
using namespace std;
int main()
{
map<string,vector<string>>obj;
int n,flag=0;
cin >> n;
for(int i=0;i<n;i++)
{
string n1,n2;
cin >> n1 >> n2;
vector<string> s;
// s.push_back(n2);
auto it = obj.find(n1);
if(it!=obj.end())
{
(it->second).push_back(n2);
}
else
{
s.push_back(n2);
obj.insert(pair<string,vector<string>>(n1,s));
}
}
cout<<"enter cate";
string n1;
cin >> n1;
// for(int i=0;i<obj.size();i++)
// {
auto it = obj.find(n1);
if(it!=obj.end())
{
vector<string> ob = it->second;
for(int i=0;i<ob.size();i++)
{
cout << ob[i]<< " ";
}
}
// }
return 0;
}