【华为OJ】解析报文,加括号,=变,
来源:互联网 发布:淘宝人气是什么意思 编辑:程序博客网 时间:2024/05/16 01:07
#include<iostream>#include<string>#include<vector>using namespace std;int _tmain(int argc, _TCHAR* argv[]){string str;cin >> str;//初始化变量vector<string> svec;string word;string seq1=",";string seq2="=";string::size_type start= 0,end = 0,wordLen;cout <<"[";while((start=str.find_first_not_of(seq1,end))!=string::npos)//单词开始{end = str.find_first_of(seq1,start);if(end == string::npos)wordLen = str.size()-start;else{wordLen = end - start;}word.assign(str.begin()+start,str.begin()+start+wordLen);start = str.find_first_not_of(seq2,end);string::size_type pos= word.find_first_of(seq2);word[pos] = ',';cout << "[" << word <<"]" ;}cout << "]";cout <<endl;system("pause");return 0;}
#include<iostream>#include<string>using namespace std;void replaceStr(string &input){//string::size_type startpos = 0,endpos=0;//startpos = input.find_first_not_of(',')//找到下一个单词的起始位置//while(startpos != string::)cout << "[" ;string::size_type pos = input.find_first_of(',');while(pos != string::npos){string::iterator iter = input.begin();for(;*iter!= input[pos];iter++){if(*iter == '=')*iter = ',';}cout <<"[" << input.substr(0,pos) << "],";input.erase(0,pos+1);pos=input.find_first_of(',');}string::iterator iter = input.begin();if(pos == string::npos){for(;iter!=input.end();iter++){if(*iter == '=')*iter= ',';}cout <<"[" << input.substr(0) << "]";cout << "]" << endl;}}int _tmain(int argc, _TCHAR* argv[]){string input;cin >> input;replaceStr(input);system("pause");return 0;}
0 0
- 【华为OJ】解析报文,加括号,=变,
- 【华为OJ】 字符串加解密
- 华为OJ 字符串加解密
- 华为oj: 字符串加解密
- 华为oj字符串加解密
- 华为oj:字符串加解密
- 华为oj 字符串加解密
- [华为OJ] 字符串加解密
- 【华为OJ】字符串加解密
- 【华为 OJ 】字符串加解密
- 华为OJ 字符串加解密
- 华为OJ 字符串加解密
- 华为OJ(参数解析)
- 【华为OJ】【048-参数解析】
- 【华为oj】超长正整数想加
- 华为OJ(字符串加解密)
- 华为OJ题库_字符串加解密
- 华为OJ平台题:字符串加解密
- 判断一个字符串中的字符是否唯一
- http://movie.douban.com/doulist/12825934/
- gdb输出stl-终结者
- [转] 应聘时最漂亮的回答! 留着 早晚用的上
- MYSQL和ORACLE的一些区别
- 【华为OJ】解析报文,加括号,=变,
- 总结oninput、onchange与onpropertychange事件的用法和区别
- 【webservice】关于完整的webservice发布系统的开发思路
- http://movie.douban.com/doulist/12825932/
- UML之轻松入门(4)-OCP做一个上进的厨子
- 手势跟踪论文学习:Realtime and Robust Hand Tracking from Depth(三)Cost Function
- mfc vcl
- 黑马程序员---面试题之银行业务系统
- 获取指定文件所在的目录的三种方法