题目:按长度为8拆分每个字符串后输出到新的字符串数组,长度不是8整数倍的字符串请在后面补数字0,空字符串不处理。
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
while(cin>>n)
{
while(n--)
{
string s;
cin>>s;
int len=s.size();
int i=0;
while(i<len)
{
if(i%8==0&&i!=0)
{
cout<<endl;
}
cout<<s[i];
i++;
}
//当字符串整除时,不需要添加0哦
if(len%8!=0) {
int c=8-len%8;
if(c!=0)
{
while(c--)
cout<<'0';
}
}
cout<<endl;
}
}
return 0;
}