题解 | #字符串分隔#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void process(vector<string>& res, string& s){
while(s.size() % 8 != 0){
s += "0";
}
for(int i = 0; i < s.size() - 7; i += 8){
string tmp = s.substr(i, 8);
//cout<<tmp<<endl;
res.push_back(tmp);
}
}
int main(){
string str = "";
vector<string> res;
while(cin>>str){
process(res, str);
}
for(int i = 0; i < res.size(); i++){
cout<<res[i]<<endl;
}
return 0;
}
华为题库题解 文章被收录于专栏
牛客华为题库的题解