NOe挖礦新增節點
『壹』 C++鏈表如何實現節點交換
c++鏈表實現節點轉換有兩種方法:
1)結點交換時機上可以看成是節點里的值交換;
2)直接把節點的地址next的指向改變。
例如:交換LnodeA和LnodeB
用while找到節點的前一個節點pA->next = LnodeA,pB->next = LndoeB
然後pTemp = LnodeA->next;
pB->next = LnodeA;
LndoeA ->next = LnoedeB->next;
pA->next = LndoeA;
LnodeA->next = pTemp;
『貳』 跪求關於c語言多叉樹添加節點的問題
數據結構:
struct list
{
/* other data */
int effectif_class_1;
int effectif_class_2;
struct list *parent;
struct list *child[];
}
struct list * findNode(struct list *point)
{
int i;
if(point->data == data)
return point;
i=0;
while(point->child[i] != NULL){
if( (findNode(point->child[i])) == point->child[i])
return point->child[i];
i++;
}
return NULL;
}
void addNode_changeNoeud(struct list *point)
{
int i=0;
while(point->child[i] != NULL)
{
point->child[i]->Noeud ++;
addNode_changeNoeud(point->child[i]);
i++;
}
}
void addNode(struct list *point, /* data */)
{ //在point的最右端插入一個子節點
int i=0;
/* 定位到最右端 */
while(point->child[i] != NULL){
i++;
}
point->child[i] = (struct list *)malloc(sizeof(struct list));
/* 保存其他數據到 point->child[i]->data */
/* 更改所有父節點的 effectif_class */
struct list *tmp;
tmp = point->parent;
while(tmp != NULL){
tmp->effectif_class_1 = tmp->effectif_class_1 + /* effectif_class_1 */ ;
tmp->effectif_class_2 = tmp->effectif_class_2 + /* effectif_class_2 */ ;
tmp = tmp->parent;
}
/* 插入節點後,更新編號 */
point->child[i] = point->child[i-1] + 1;
addNode_changeNoeud(point); /* 這個不好說,用於更新編號Noeud的,自己理解吧... */
}
『叄』 c++ 鏈表節點有兩種類型.怎麼實現
1)結點交換時機上可以看成是節點里的值交換;
2)直接把節點的地址next的指向改變。
例如:交換LnodeA和LnodeB
用while找到節點的前一個節點pA->next = LnodeA,pB->next = LndoeB
然後pTemp = LnodeA->next;
pB->next = LnodeA;
LndoeA ->next = LnoedeB->next;
pA->next = LndoeA;
LnodeA->next = pTemp;