题解 | #字符串分隔#
字符串分隔
https://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
//C语言的逐个字符操作
#include <string>
#include<stdio.h>#include <stdlib.h>
#include <vector>
#include <iostream>
using namespace std;
int main() {
char c;
int i = 0;
bool first = true;
c = getchar();
if ( c == '\n')
return 0;
else
{
putchar(c);
while (c = getchar())
{
i++;
if (i == 8) {
putchar('\n');
i = 0;
}
if (c != '\n'){
putchar(c);
}
else if ( i != 0) {
int j = 8 - i;
while (j > 0) {
j--;
putchar('0');
}
return 0;
}
else
return 0;
}
}
return 0;
}