•連續輸入字符串,請按長度爲8拆分每個字符串後輸出到新的字符串數組;
•長度不是8整數倍的字符串請在後面補數字0,空字符串不處理。
輸入描述:
連續輸入字符串(輸入2次,每個字符串長度小於100)
輸出描述:
輸出到長度爲8的新字符串數組
示例1
輸入
abc
123456789
輸出
abc00000
12345678
90000000
#include<iostream>
#include<string>
using namespace std;
void fun(string s){
if(s.length()<=8){
int j=8-s.length();
for(int i=0;i<j;i++){
s+='0';
}
cout<<s<<endl;
}
else{
string s1(s,0,8);
cout<<s1<<endl;
s.erase(0,8);
fun(s);
}
}
int main(){
string str;
while(cin>>str){
fun(str);
}
return 0;
}