华为机试:字符串分隔
#include <iostream>
#include <string>
using namespace std;
int main() {
string str;
getline(cin, str);
int count=0;
for(char ch:str)
{
cout << ch;
count++;
if(count == 8)
{
cout << endl;
count = 0;
}
}
if(count < 8 && count != 0)
{
while(count < 8)
{
cout << 0;
count++;
}
cout << endl;
}
return 0;
}

查看17道真题和解析