C语言,急急急!!!!!!!!!!

来源:百度知道 编辑:UC知道 时间:2024/05/21 18:51:42
以字符串的形式输入一个八进制数,转为二进制输出

要用C语言阿

#include <stdio.h>
#include <string.h>

#define H0 "000"
#define H1 "001"
#define H2 "010"
#define H3 "011"
#define H4 "100"
#define H5 "101"
#define H6 "110"
#define H7 "111"

void main()
{
char sh[100];
char sb[100];
int i;
int len;
sh[0] = 0x00;
sb[0] = 0x00;
scanf("%s",sh);
for(i=0;i<strlen(sh);i++)
{
switch(sh[i])
{
case '0': strcat(sb,H0);break;
case '1': strcat(sb,H1);break;
case '2': strcat(sb,H2);break;
case '3': strcat(sb,H3);break;
case '4': strcat(sb,H4);break;
case '5': strcat(sb,H5);break;
case '6': strcat(sb,H6);break;
case '7': strcat(sb,H7);break;
}
}
i = 0;
len = strlen(sb);
while