Family Tree
Family Tree
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node {
char name[20];
};
int n ;
int i;
for (i=0;i<n;i++){
return NULL;
strcpy(newnode->name, a);
newnode->child = NULL;
newnode->parent = NULL;
newnode->siblings = NULL;
nodes[n] = newnode;
n++;
return newnode;
while(p!=NULL){
if (q!=NULL) return q;
p = p->siblings;
return NULL;
q->child = p;
p->parent = q;
}
else if (p==NULL && q != NULL){
r->siblings = p;
p->parent = q;
q->child = p;
p->parent = q;
else{
r->siblings = p;
p->parent = q;
}*/
childnode->parent = parentnode;
childnode->siblings = parentnode->child;
parentnode->child = childnode;
if (r==NULL)return 0;
int c = 1;
struct node *p ;
c += count(p);
return c;
if (r==NULL) return 0;
int max = 0;
int h = height(p);
if (max<h) max = h;
return max+1;
void run() {
char child[30];
char parent[30];
while (1){
scanf("%s", child);
scanf("%s", parent);
char query[30];
char name[30];
while (1){
scanf("%s", query);
scanf("%s", name);
scanf("%s", name);
int main(){
n = 0;
run();