拆分输出字符串
//题目描述:连续输入字符串(输出次数为 N, 字符串长度小于 100),请按长度为 8 拆分每个字符
//串后输出到新的字符串数组,长度不是 8 整数倍的字符串请在后面补数字 0,空字符串不处理。
//首先输入一个整数,为要输入的字符串个数。
//例如:
//输入:2
//abc
//12345789
//输出:abc00000
//12345678
//90000000
#include<iostream>
#include<string>
using namespace std;
int main(){
string str="";
while(getline(cin,str)){
if(str.size()<=8){
str.append(8-str.size(),'0');
cout<<str<<endl;
}
else {
while(str.size()>8){
cout<<str.substr(0,8)<<endl;
str=str.substr(8,str.size()-8);
}
if(str.size()>0){
cout<<str.append(8-str.size(),'0')<<endl;
}
}
}
return 0;
}