-
백준 12605번: 단어순서 뒤집기문자열(String) 2018. 8. 4. 15:34반응형
https://www.acmicpc.net/problem/12605
1. 문제
2. 알고리즘
키워드 - 문자열, 구현
3. 코드
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051#include <iostream>#include <sstream>#include <string>#include <algorithm>#include <functional>#include <vector>#include <list>#include <queue>#include <deque>#include <map>#include <set>#include <stack>#include <math.h>#include <memory.h>using namespace std;#define MAX_SIZE 100#define INF 0x7fffffff#define CENDL "\n"#define ll long longint main() {cin.tie(0);std::ios::sync_with_stdio(false);int n; cin >> n;cin.ignore();for(int i = 1; i <= n; i ++) {string str;getline(cin, str);reverse(str.begin(), str.end());str += ' ';vector<string> vc;int len = str.size();int start = 0;for (int end = 0; end < len; end++) {if (str[end] == ' ') {reverse(str.begin() + start, str.begin() + end);start = end + 1;}}cout << "Case #" << i << ": " << str << endl;}return 0;}cs 반응형'문자열(String)' 카테고리의 다른 글
백준 6996번: 애너그램 (0) 2018.08.05 백준 5026번: 박사 과정 (0) 2018.08.05 백준 12780번: 원피스 (0) 2018.08.03 백준 9324번: 진짜 메시지 (0) 2018.07.31 백준 15881번: Pen Pineapple Apple Pen (0) 2018.07.29