沒有人知道如何將值保存到左側或右側的二叉樹中? 比如我們有2層結構:用函數訪問struct,如何保存值?
struct A
{
int a;
struct A *left;
struct A *right;
}
struct B
{
A *root;
}
,我們有一個功能:
void insert(B *tree, int value)
{
if(tree== NULL)
{
tree= (B*) malloc (sizeof(B));
}
else if(tree!=NULL)
{
tree->root->a = value;
tree->root->left = NULL;
tree->root->right = NULL;
}
現在我們有根... 但如何initiliase在右側和左側的價值?
else if(tree->apointer->a< value)
{
tree->root->left = value // with & wont work cause is a pointer to integer
}
有誰知道?
在此先感謝
除非您使用在智能手機在火車上站起來VI,您的編碼風格是絕對應該受到譴責。 – Bathsheba
請聯繫你的老師。您在教學情境中需要解決某些核心概念而非問答網站時存在根本性問題。 – Arkadiy