Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 정석학술정보관
- 브루트포스
- 컴공과
- 코테
- 그래프
- 너비우선탐색
- Computer science
- 백준
- coding
- 구현
- Stack
- DP
- 컴퓨터공학과
- 개발
- 코딩
- 오에스
- 자료구조
- Operating System
- cs
- 스택
- 북리뷰
- 오퍼레이팅시스템
- 정석
- bfs
- 알고리즘
- 컴공
- vector
- c++
- OS
- 문제풀이
Archives
- Today
- Total
Little Jay
[C++] 백준 9093번 - 단어 뒤집기 본문
string을 잘 split하고 reverse 하면 풀 수 있는 문제
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
using namespace std;
vector<string> split(string input, char delimiter) {
vector<string> answer;
stringstream ss(input);
string temp;
while (getline(ss, temp, delimiter)) {
answer.push_back(temp);
}
return answer;
}
int main() {
int n;
cin >> n;
cin.ignore();
for (int i = 0; i < n; i++) {
string s;
getline(cin, s);
vector<string> v = split(s, ' ');
for (int i = 0; i < v.size(); i++) {
reverse(v[i].begin(), v[i].end());
cout << v[i] << " ";
}
cout << "\n";
}
return 0;
}
'알고리즘 > BOJ' 카테고리의 다른 글
[C++] 백준 1850번 - 최대공약수 (0) | 2021.08.21 |
---|---|
[C++] 백준 5430번 틀 (0) | 2021.08.20 |
[C++] 백준 2606번 - 바이러스 (0) | 2021.08.19 |
[C++] 백준 11724번 - 연결 요소의 개수 (0) | 2021.08.19 |
[C++] 백준 1260번 - DFS와 BFS (0) | 2021.08.19 |
Comments