erp系统免费版,优化大师优化项目有哪些,腾讯企点怎么群发,云南建设局网站首页链接#xff1a;
722. 删除注释
题意#xff1a;
如题#xff0c;特殊规则见链接
解#xff1a;
字符串处理#xff0c;嗯写就完事了,主要是判断指针位置和特殊规则
实际代码#xff1a;
#includebits/stdc.h
using namespace std;
vectorstring …链接
722. 删除注释
题意
如题特殊规则见链接
解
字符串处理嗯写就完事了,主要是判断指针位置和特殊规则
实际代码
#includebits/stdc.h
using namespace std;
vectorstring removeComments(vectorstring source)
{vectorstringans;int zt0;//zt状态标识符 1进入块注释string temp;for(auto s:source){int lgs.size();//couts:szt:ztendl;for(int i0;ilg;i){if(s[i]/zt0){if(s[i1]/) break;//行注释退出else if(s[i1]*)//块注释{zt1;i;i;}}if(zt0) temp.push_back(s[i]); if(zt1i1lgs[i]*s[i1]/)//块注释结尾{zt0;i;}}if(zt0!temp.empty())//不在块注释且非空{ans.push_back(temp);temp.clear();}//couttempline:tempendl;}return ans;
}
int main()
{vectorstringsource;string temp;while(getline(cin,temp)){source.push_back(temp);}vectorstringansremoveComments(source);for(auto a:ans) coutline:aendl;return 0;
}限制
1 source.length 1000 source[i].length 80source[i] 由可打印的 ASCII 字符组成。每个块注释都会被闭合。给定的源码中不会有单引号、双引号或其他控制字符。