#include<stdio.h>
#include<stdlib.h>
char buf[128];
struct student {int id; char name[32]; int score; };
typedef struct student datatype;
struct node{ datatype data; struct node *left,*right; };
void bst_insert(struct node t,struct student d){
/*ここが知りたい/
}
void print_bst_dummy(struct node *t,struct node *dummy){
if(t==dummy)
printf(".\n");
else{
printf("%d,%s,%d\n",t->data.id,t->data.name,t->data.score);
print_bst_dummy(t->left,dummy);
print_bst_dummy(t->right,dummy);
}
return;
}
void print_bst(struct node *t){
print_bst_dummy(t->right,t->left);
return;
}
int main(){
struct node *t=get_tree();
struct student d;
while(fgets(buf,sizeof(buf),stdin)!=NULL){
sscanf(buf,"%d,%[^,],%d",&st.id,st.name,&st.score);
bst_insert(t,st);
}
print_bst(t);
return 0;
}
こちらも自己解決ができなかったので相談させてもらいます。ここが知りたいの部分の関数埋めをしてほしいです。
ちなみにbst_insert関数は構造体nodeのアドレスtの指す節点を根とする二分探索木に構造体studentの値dをメンバdataとする節点を追加し得られた二分探索木の根の節点のアドレスを返す関数である。
あなたの回答
tips
プレビュー