k*r
1 楼
Write a method: Node* Copy(Node* root)
that takes a pointer to a Node structure as a parameter. The
Node structure contains two pointers to other Node structures. The function
should return a complete copy of the passed-in data structure.
请问是这样做吗?
typedef struct node{
int value;
struct node *child1;
struct node *child2;
}Node;
Node* Copy(Node* root){
Node *n = new Node;
Copywrapper(n, root);
return n;
}
void Copywrapper(Node* n, Node* root){
if(!root) return;
n->v
that takes a pointer to a Node structure as a parameter. The
Node structure contains two pointers to other Node structures. The function
should return a complete copy of the passed-in data structure.
请问是这样做吗?
typedef struct node{
int value;
struct node *child1;
struct node *child2;
}Node;
Node* Copy(Node* root){
Node *n = new Node;
Copywrapper(n, root);
return n;
}
void Copywrapper(Node* n, Node* root){
if(!root) return;
n->v