o*********7 发帖数: 101 | 1 Write a parser for the following format
( a, b ):( c, d ):( e, f ):...
assume the data resides in a std::string
What data structure will you parse it into and outline your parser.
对STL不算太熟悉,稍微知道一点点
不知道是放在map里面比较好还是放在list里面更合适
请指教,非常感谢 | m*f 发帖数: 8162 | 2 I would first ask the interviewer if I am allowed to use the newer version
of C++, which includes a regex, then it's going to be pretty simple - just
match and search.
If this is not the case, when I would first split string by ":", and then
split string by ",". You may want to ask if you need to handle things like:
(hello:world, 1):(information:retrieval, 2):(apple:rotton, 3):...
If this is the case, then it's a bit more complicated, you will want to
implement a bottom-up regular expression parser...
【在 o*********7 的大作中提到】 : Write a parser for the following format : ( a, b ):( c, d ):( e, f ):... : assume the data resides in a std::string : What data structure will you parse it into and outline your parser. : 对STL不算太熟悉,稍微知道一点点 : 不知道是放在map里面比较好还是放在list里面更合适 : 请指教,非常感谢
| q*i 发帖数: 78 | 3 why not use "):(" as delimiter
like:
【在 m*f 的大作中提到】 : I would first ask the interviewer if I am allowed to use the newer version : of C++, which includes a regex, then it's going to be pretty simple - just : match and search. : If this is not the case, when I would first split string by ":", and then : split string by ",". You may want to ask if you need to handle things like: : (hello:world, 1):(information:retrieval, 2):(apple:rotton, 3):... : If this is the case, then it's a bit more complicated, you will want to : implement a bottom-up regular expression parser...
| m*f 发帖数: 8162 | 4 It's pretty fragile..
【在 q*i 的大作中提到】 : why not use "):(" as delimiter : : like:
| h*****3 发帖数: 1391 | | w****f 发帖数: 684 | 6 请教,哪个版本C++ 有regex? what is regex?
like:
【在 m*f 的大作中提到】 : I would first ask the interviewer if I am allowed to use the newer version : of C++, which includes a regex, then it's going to be pretty simple - just : match and search. : If this is not the case, when I would first split string by ":", and then : split string by ",". You may want to ask if you need to handle things like: : (hello:world, 1):(information:retrieval, 2):(apple:rotton, 3):... : If this is the case, then it's a bit more complicated, you will want to : implement a bottom-up regular expression parser...
| d****n 发帖数: 1637 | 7 STL stack
【在 o*********7 的大作中提到】 : Write a parser for the following format : ( a, b ):( c, d ):( e, f ):... : assume the data resides in a std::string : What data structure will you parse it into and outline your parser. : 对STL不算太熟悉,稍微知道一点点 : 不知道是放在map里面比较好还是放在list里面更合适 : 请指教,非常感谢
| C***U 发帖数: 2406 | 8 用map怎么样?
第一位是key
第二位是value
【在 o*********7 的大作中提到】 : Write a parser for the following format : ( a, b ):( c, d ):( e, f ):... : assume the data resides in a std::string : What data structure will you parse it into and outline your parser. : 对STL不算太熟悉,稍微知道一点点 : 不知道是放在map里面比较好还是放在list里面更合适 : 请指教,非常感谢
| w********s 发帖数: 1570 | |
|