我浏览了this,但在第114行写的是printf("%d -> ", t->value);
我问的是,"%d ->
是什么意思?这是拼写错误还是别的什么?
示例:
struct btnode {
int value;
struct btnode * l;
struct btnode * r;
} * root = NULL, * temp = NULL, * t2, * t1;
void inorder(struct btnode * t) {
if (root == NULL) {
printf("No elements in a tree to display");
return;
}
if (t->l != NULL)
inorder(t->l);
printf("%d -> ", t->value);
if (t->r != NULL)
inorder(t->r);
}
答案 0 :(得分:5)
没什么特别的,只是普通的格式字符串。
printf("%d -> ", 42);
输出:
42 ->
答案 1 :(得分:3)
这意味着这段代码将以十进制打印t->value
的值,后跟字符->
。没什么特别的,只是普通的printf
答案 2 :(得分:3)
%d
表示打印int,如方法(t->value
)中稍后所述。 ->
部分只是打印->
。
答案 3 :(得分:3)
它只是打印一个数字(%d),然后是ASCII箭头 - >。没有错误。
答案 4 :(得分:3)
没有特殊意义
由于您正在使用二叉树概念,以说明元素绑定和链接
Suppose you have a binary tree already constructed like this one:
15
/ \
10 30
/ \ \
5 13 35
如果你在IN-ORDER中遍历树,那么下面的printf会像这样打印:
printf("%d -> ", t->value);
5 -> 10 -> 13 -> 15 -> 30 -> 35