| 일 | 월 | 화 | 수 | 목 | 금 | 토 | 
|---|---|---|---|---|---|---|
| 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
													
											
												
												- 이진탐색
 - Stored Procedure
 - two pointer
 - MYSQL
 - Two Points
 - 스토어드 프로시저
 - Brute Force
 - 다익스트라
 - Dijkstra
 - DP
 - union find
 - 그래프
 - String
 - Hash
 - binary search
 - Trie
 - SQL
 
													Archives
													
											
												
												- Today
 
- Total
 
codingfarm
StrTok 본문
| 
 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 
38 
39 
40 
 | 
 #include<iostream> 
#include<string> 
#include<vector> 
using namespace std; 
// ex) 2016-09-15 20:59:57.421 0.351s 
// 2016-09-15 20:59:58.299 8 
void StrTok(string& org, vector<string>& ret, const string& delims) { 
    ret.clear(); 
    string new_str; 
    for (int index = 0; index < org.size(); index++) { 
        for (int i = 0; i < delims.size(); i++) { 
            if (org[index] == delims[i]) { 
                ret.push_back(new_str); 
                new_str.clear(); 
                index++; 
                break; 
            } 
        } 
        new_str.push_back(org[index]); 
    } 
    if (new_str[0] != '\0') 
        ret.push_back(new_str); 
} 
int main(void) { 
    string delims = ":. s"; 
    string str = "2016-09-15 20:59:57.421 0.351s"; 
    vector<string> ret; 
    StrTok(str, ret, delims); 
    str = "2016-09-15 20:59:58.299 8"; 
    StrTok(str, ret, delims); 
    return 0; 
} 
 | 
cs | 
'Algorithm & Data structure > 이론' 카테고리의 다른 글
| 후위 표기법 (0) | 2021.05.18 | 
|---|---|
| 그래프 문제 모음 (0) | 2021.04.23 | 
| 충돌 여부 검사 (0) | 2021.04.21 | 
| 정렬된 데이터를 이진탐색으로 슬라이싱 하기(lower_bound, upper_bound) (0) | 2021.04.21 | 
| Dijkstra, Bellman-Ford, Floyd-Warshall (0) | 2021.04.20 | 
			  Comments