[英]What does “%d ->” in printf mean?
我瀏覽了一下,但在第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);
}
沒什么特別的,只是普通格式的字符串。
printf("%d -> ", 42);
輸出:
42 ->
這意味着這段代碼將以十進制打印t->value
,后跟字符->
。 沒什么特別的,只是普通的printf
%d
表示要打印int,如稍后在method( t->value
)中所述。 ->
部分只是打印->
。
它只打印一個數字(%d),后跟一個ASCII箭頭->。 沒有錯
沒有特別的意義
由於您使用的是二叉樹概念,因此可以說明元素與鏈接綁定在一起
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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.