- 连续输入字符串,请按长度为8拆分每个字符串后输出到新的字符串数组;
•长度不是8整数倍的字符串请在后面补数字0,空字符串不处理。
#include <stdio.h>
#include <string.h>
int main(void)
{
char str[1000];
while(scanf("%s", str) != EOF)
{
int len = strlen(str);
for(int i = 0; i < len; i++)
{
printf("%c", str[i]);
if ((i+1)%8 == 0)
printf("\n");
}
int res = 8-len%8;
while(res>0 && res<8)
{
printf("%c", '0');
res--;
if (res == 0)
printf("\n");
}
}
}
2、写出一个程序,接受一个十六进制的数,输出该数值的十进制表示。(多组同时输入 )
int main()
{
int x =0x0;
while(~scanf("%x",&x))
{
printf("%d\n",x);
}
return 0;
}
3、