-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLv5_오픈채팅방.cpp
More file actions
37 lines (33 loc) · 832 Bytes
/
Lv5_오픈채팅방.cpp
File metadata and controls
37 lines (33 loc) · 832 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
#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <map>
using namespace std;
vector<string> solution(vector<string> record) {
vector<string> answer;
map<string, string> info;
for (int i = 0; i < record.size(); ++i) {
stringstream ss;
ss.str(record[i]);
string command, uid, nick;
ss >> command;
ss >> uid;
ss >> nick;
if (command == "Enter" || command=="Change") // 입장, 닉네임 변경
info[uid] = nick;
}
for (int i = 0; i < record.size(); ++i) {
stringstream ss;
ss.str(record[i]);
string command, uid, nick;
ss >> command;
ss >> uid;
ss >> nick;
if (command == "Enter")
answer.push_back(info[uid]+"님이 들어왔습니다.");
else if (command == "Leave")
answer.push_back(info[uid] + "님이 나갔습니다.");
}
return answer;
}