题解 | #字符串分隔#
字符串分隔
http://www.nowcoder.com/practice/d9162298cb5a437aad722fccccaae8a7
include<stdio.h>
include<string.h>
int main()
{
char str[1000];
int len = 0;
int tim = 0;
while( scanf("%s", str) !=EOF)
{
len = strlen(str);
tim = len%8;
if(len > 0)
{
if(tim == 0)
{
for(int i = 0;i < (len/8);i++)
{
for(int j = 0;j <8;j++)
{
printf("%c",str[i*8+j]);
}
printf("\n");
}
}
else
{
for(int i = 0;i <(len/8);i++)
{
for(int j = 0;j <8;j++)
{
printf("%c",str[i*8+j]);
}
printf("\n");
}
for(int i = 0;i <tim;i++)
{
printf("%c",str[(len/8)*8 + i]);
}
for(int i = 0;i <8-tim;i++)
{
printf("%c",'0');
}
printf("\n");
}
}
}
return 0;}
查看16道真题和解析