题解 | #计算某字符出现次数#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include<iostream> #include<string> using namespace std; int main() { string s, s_tem = ""; cin >> s; int n = s.size(); int n2 = n/8; int m = 8 - n%8; for(int i = 0; i < n2; i++) { cout << s.substr(8*i, 8) << endl; } if(n%8 != 0) { s_tem = s.substr(8*n2, 8-m); for(int i = 0; i< m; i++) s_tem = s_tem + "0"; cout << s_tem << endl; } return 0; }