트리 질문이요
들샘
질문 제목 : 트리 질문이요질문 요약 :녹색주석으로 된 부분 어떻게 짜야하는지좀 알려주세요 ㅠㅜ질문 내용 :
/*다음은 BST를 이용한 사전의 목차를 출력하는 프로그램이다.
- bst.dat 에서 각 단어들과 단어들이 있는 페이지를 입력받아 구조체에 저장할 것
- 구조체에 저장한 데이터를 BST에 삽입할것
- 삽입한 데이터를 역순으로 (z, y, ....a) 순으로 페이지와 함께 출력할것.*/
#include stdio.h
#include stdlib.h
#include string.h
#include BST_ADT.h
int compare (void* num1, void* num2);
void printBST (void* num1);
int main (void){
// Local Definitions
BST_TREE* BSTRoot;
FILE *fp;
char datain[20];
BSTRoot = BST_Create (compare);
printf(Reading words;\n);
if((fp=fopen(bst.dat, r)) == NULL) {
puts(file open error: Cannot find bst.dat);
return (-1);
}
while((fscanf(fp, %s, datain))!=EOF){
// insert read data into BST
}
printf(\nBST contains:\n);
BST_Traverse (BSTRoot, printBST);
BST_Destroy (BSTRoot);
return 0;
}
// main
int compare (void* num1, void* num2)
{
// 읽은 단어를 비교하는 함수
return 1;
} // compareInt
void printBST (void* num1)
{
// BST 내의 단어를 페이지와 함께 출력하는 함수
} // printBST
/*데이터 파일
예제
samsung
32
boy
89
cancel
100
abeek
490
guns
80
출력
예제
Reading words;
Inserting samsung @ page 32
Inserting boy @ page 89
Inserting cancel @ page 100
Inserting abeek @ page 490
Inserting guns @ page 80
BST contains:
samsung 32
guns 80
cancel 100
boy 89
abeek 490*/