题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
#include <string>
//#include <stdlib>
#include <vector>
#include <iostream>
using namespace std;
int main() {
char hhh[101];
cin.getline(hhh, 101);
string outStr;
int Eit;
Eit=8;
for(int i=0;hhh[i]!='\0';++i)
{
outStr.push_back(hhh[i]);
if((i+1)%8==0)
{
cout<<outStr<<endl;
outStr.clear();
}
}
if(outStr.size()!=0)
{
int resid=outStr.size();
for(int i=resid;i<8;++i)
{
outStr.push_back('0');
}
cout<<outStr<<endl;
}
}
//#include <stdlib>
#include <vector>
#include <iostream>
using namespace std;
int main() {
char hhh[101];
cin.getline(hhh, 101);
string outStr;
int Eit;
Eit=8;
for(int i=0;hhh[i]!='\0';++i)
{
outStr.push_back(hhh[i]);
if((i+1)%8==0)
{
cout<<outStr<<endl;
outStr.clear();
}
}
if(outStr.size()!=0)
{
int resid=outStr.size();
for(int i=resid;i<8;++i)
{
outStr.push_back('0');
}
cout<<outStr<<endl;
}
}