제5장 트리 - 단어 빈도수 출력( 상호 참조 생성기 )
- 최초 등록일
- 2006.09.29
- 최종 저작일
- 2006.08
- 압축파일
- 가격 3,000원
소개글
3. [프로그래밍 프로젝트] 이 프로젝트에서는 상호 참조 생성기를 작성하는 것이다.
텍스트 파일 ( 링컨의 게티스버그 연설문이 좋은 예가 된다. )이 있다고 가정하자. 파일을 읽고 다음 형식을 이용하여 파일의 모든 단어를 알파벳 순서로 프린트 하려고 한다.
단어 | 출현 횟수 | 단어가 출현한 줄
상호참조 생성기가 대소문자 구별은 하지 않는 것으로 가정하라. 즉 단어 Did와 did는 동일하다. 예를 들어 Lewis Carroll의 시 Jabberwocky의 첫 두 줄을 이용하여 상호 참조 생성기를 실행 했을 때 다음 출력을 생성한다.
1 Twas billing and the slithy toves
2 Did gyre and gimble in the wabe
Word Count Lines
and 2 1 2
brilling 1 1
gimble 1 2
gyre 1 2
in 1 2
slithy 2 1 2
the 2 1 2
toves 1 1
was 1 2
wabe 1 2
Total 1 1
1) 거의 line by line으로 상세한 주석을 달았습니다.
2) 몇 가지 standard library 에 대한 사용법을 공부 하셔야 합니다.
컴파일 실행환경
vc++ 6.0
본문내용
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
typedef short bool;
#define FALSE 0
#define TRUE 1
typedef struct _WORDNODE *PWORDNODE;
typedef struct _LINENODE *PLINENODE;
typedef struct _LINENODE // 단어가 출현시 그 라인번호에 대한 구조체.
{
int line_number; // 라인번호.
PLINENODE next_node; // 다음 노드
} LINENODE;
typedef struct _WORDNODE // Binary Search Tree의 노드 구조체.
{
char word[32]; // 단어.
int frequency; // 빈도수
PLINENODE pLine_node; // 단어가 나오는 라인번호 (Linked List로 구현)
PWORDNODE left_child; // 왼쪽자식노드
PWORDNODE right_child; // 오른쪽자식노드
} WORDNODE;
/************************************************************************
* Function Prototype Declare
************************************************************************/
압축파일 내 파일목록
Problem_03_Generator/
Problem_03_Generator/a.txt
Problem_03_Generator/cross_reference_generator.c
Problem_03_Generator/Problem_03_Generator.dsp
Problem_03_Generator/Problem_03_Generator.dsw
Problem_03_Generator/Problem_03_Generator.ncb
Problem_03_Generator/Problem_03_Generator.opt
Problem_03_Generator/Problem_03_Generator.plg
Problem_03_Generator/Problem_03_Generator.positions
참고 자료
없음