728x90
반응형
20291 파일정리
문제풀이
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
using namespace std;
void fast_io(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
map<string,int> ma;
int n;
vector<string> split(string str, char del){
istringstream iss(str);
string buf;
vector<string> res;
while(getline(iss,buf,del)){
res.push_back(buf);
}
return res;
}
int main(void)
{
fast_io();
cin >> n;
while(n--)
{
string str;
cin >> str;
vector<string> res = split(str, '.');
ma[res[1]]++;
}
for (auto iter = ma.begin(); iter != ma.end();iter++)
cout << iter->first<< " " << iter->second << "\n";
}
.을 기준으로 맵에 넣어준뒤 값을 출력했다.
728x90
반응형
'자라는 개발자 > 문제풀이' 카테고리의 다른 글
백준 c++ 11292 키 큰 사람 (0) | 2022.06.07 |
---|---|
백준 c++ 16212 정열적인 정렬 (0) | 2022.06.06 |
백준 c++ 17254 키보드이벤트 (0) | 2022.06.02 |
백준 c++ 10709 기상캐스터 (0) | 2022.05.29 |
백준 c++ 2303 숫자 게임 (0) | 2022.05.22 |