私の目標は、「ecdgaf b」と入力すると、出力は
e
(\t) c <- first left node
(\t)(\t) a <- second left node
(\t)(\t)(\t) b <- third right node
(\t)(\t) d <- second right node
(\t) g <- first right node
(\t)(\t) f <- second left node
しかし、意図したとおりに動作させることはできません。
これは、Brian W. Kernighan と Dennis M. Ritchie による「C プログラミング言語」の例です。
関数を変更しました。出力ウィンドウで \t を確認するにはどうすればよいですか。
私の試み:
void prt(AW *p)
{
int j;
int temp;
if(p != NULL)
{
temp = judge;
while(1)
{ temp = temp / 2;
count++;
if(temp == 0)
break;
}
for(j=1; j<count; j++)
putchar('\t');
printf("%-16s\n",p->word);
count=0;
if(p->left != NULL)judge++;
prt(p->left);
if(p->right != NULL)judge++;
prt(p->right); }
}