Remove Nested Comments.
来源:互联网 发布:三只松鼠 淘宝 编辑:程序博客网 时间:2024/06/06 09:05
Comments can be single line using //, or multiple line using /* */
We can use two flags to make the begin and end of two types of comments.
string removeComments(string str) { string res; bool s_comment = false; bool m_comment = false; int n = str.size(); for(int i = 0; i < n; ++i) { if(s_comment == true && str[i] == '\n') { s_comment = false; } else if(m_comment == true && str[i] == '*' && str[i+1] == '/') { m_comment = false; i++; } else if(m_comment || s_comment) continue; else if(str[i] == '/' && str[i + 1] == '/') { s_comment = true; i++; } else if(str[i] == '/' && str[i+1] == '*') { m_comment = true; i++;} else res += str[i]; } return res;}
0 0
- Remove Nested Comments.
- gcc remove comments
- 722. Remove Comments
- 722. Remove Comments
- Remove source file comments using IntelliJ?
- Comments
- Comments
- How to remove the //TODO comments from auto-generated code
- struts2 comments
- Column Comments
- django comments
- Context comments
- permission comments
- Service comments
- Cursor comments
- Funny Comments
- Menu comments
- Setting comments
- AngularJs的语法介绍
- c语言 大数据乘法
- Java中equals()和==的区别
- C++第七次作业
- 在实践中应用Hadoop MapReduce 实验2 以tab space分隔的文本排序
- Remove Nested Comments.
- 创建k8s集群(仅限于理论,无实践)
- AngulaJs中的简单数据绑定
- sublime3 Scala编译环境搭建
- 再论Epool
- JSON简介
- 连载shell(二):test判断,判断符号[ ],shell script的默认变量($0, $1...),shift参数变量偏移
- JSON格式规定
- C++作业7