Professional Documents
Culture Documents
Code Bài Tập Lập Trình C Cơ Bản
Code Bài Tập Lập Trình C Cơ Bản
h>
#include <stdlib.h>
#include <iostream>
#define MAX_CHILD 2
struct Node
char id[50];
char person_name[50];
char school_name[50];
};
if (newNode == NULL)
exit(1);
strcpy(newNode->id, id);
strcpy(newNode->person_name, person_name);
strcpy(newNode->school_name, school_name);
newNode->children[i] = NULL;
}
return newNode;
if (parent->children[i] == NULL)
parent->children[i] = child;
break;
char input[256];
printf ("Enter node information (ID$Person Name$School Name$Child ID 1$Child ID 2#): ");
break;
addChild(root, newNode);
if (child1[0] != '\0') {
addChild(newNode, childNode1);
(*nodesCount)++;
if (child2[0] != '\0') {
addChild(newNode, childNode2);
(*nodesCount)++;
(*nodesCount)++;
if (root != NULL) {
displayTree(root->children[i]);
int main() {
scanf("%d", &totalNodes);
printf("Tree created:\n");
displayTree(root);
return 0;