반응형
https://www.acmicpc.net/problem/20291


#문제 해결 방법
sstream을 사용하자
#전체 코드
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
map<string, int> exts;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
stringstream ss(s);
string token;
getline(ss, token, '.');
getline(ss, token);
exts[token]++;
}
for (const auto& p : exts) {
cout << p.first << " " << p.second << "\n";
}
return 0;
}
반응형
'[백준] > C++' 카테고리의 다른 글
백준 14575번 뒤풀이 [C++] (0) | 2025.03.02 |
---|---|
백준 32867번 피아노 [C++] (0) | 2025.02.28 |
백준 24041번 성싶당 밀키트 [C++] (0) | 2025.02.19 |
백준 10975번 데크 소트2 [C++] (0) | 2025.02.19 |
백준 21738번 얼음깨기 펭귄 [C++] (0) | 2025.01.15 |
반응형
https://www.acmicpc.net/problem/20291


#문제 해결 방법
sstream을 사용하자
#전체 코드
#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n;
cin >> n;
map<string, int> exts;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
stringstream ss(s);
string token;
getline(ss, token, '.');
getline(ss, token);
exts[token]++;
}
for (const auto& p : exts) {
cout << p.first << " " << p.second << "\n";
}
return 0;
}
반응형
'[백준] > C++' 카테고리의 다른 글
백준 14575번 뒤풀이 [C++] (0) | 2025.03.02 |
---|---|
백준 32867번 피아노 [C++] (0) | 2025.02.28 |
백준 24041번 성싶당 밀키트 [C++] (0) | 2025.02.19 |
백준 10975번 데크 소트2 [C++] (0) | 2025.02.19 |
백준 21738번 얼음깨기 펭귄 [C++] (0) | 2025.01.15 |