题目
按要求分解字符串,输入两个数M,N;M代表输入的M串字符串,N代表输出的每串字符串的位数,不够补0。例如:输入2,8, “abc” ,“123456789”,则输出为“abc00000”,“12345678“,”90000000”
代码
#include<iostream>
#include<string>
#include<vector>
using namespace std;vector<string> showAll(vector<string> data, int n) {int size = data.size();vector<string> result;if (0 == size) {return result;}for (int i = 0; i < size; i++) {string inData = data[i];int length = inData.size();//补0for (int j = 0; j < n - length % n; j++) {inData += "0";}//分解int index = 0;while (index < length) {
// result.insert(result.begin(),result.size_type);result.push_back(inData.substr(index, n));index += n;}}return result;
}int main(){vector<string> data;d