#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#define LEN 100 /*出現する単語の長さの最大値*/
/*単語を登録するための構造体の定義*/
struct word_tree
{
/********要実装**********/
};
int read_word(FILE *fp, char *output)
{
int i = 0;
int c;
while(1){
c = getc(fp);
if(c == EOF){
return 0;
} else if ('A' <= c && c <= 'Z' || 'a' <= c && c<= 'z'){
break;
}
}
do{
if('A' <= c && c <= 'Z' || 'a' <= c && c<= 'z'){
output[i] = (char)tolower(c);
i++;
} else{
break;
}
c = getc(fp);
} while(1);
output[i] = '\0';
if( strcmp( output, "eor") == 0 ) return -1;
else return i;
}
struct word_tree *alloc_word_tree(void)
{
/*************要実装****************/
}
void register_word(struct word_tree *node, char *string, int length)
{
/*************要実装****************/
}
int check_word(struct word_tree* node, char *string, int length)
{
/*************要実装****************/
}
int main()
{
int length;
char input[LEN];
struct word_tree *root = alloc_word_tree();
/* 標準入力から単語を読み込み、その単語を登録する */
while ( (length = read_word(stdin, input)) != -1){
/* 読み込んだ単語とその長さを出力 */
printf("len(%s) = %d\n", input, length);
/* 読み込んだ単語を登録 */
register_word(root, input, length);
}
/* 標準入力から単語を読み込み、その単語が登録されているか否かを表示する */
while ( (length = read_word(stdin, input)) != -1){
/* 読み込んだ単語が登録されているか否かを出力 */
if ( check_word(root, input, length) == 1 ) printf("%s: Registered\n", input);
else printf("%s: Not registered\n", input);
}
return 0;
}