题目
描述:输入一篇可能未经排版的文章,挑选出其中的单词【单词中不包含“(”等特殊符号】,然后按字典序输出。 输入:从文件中读取文章 输出:按字典序输出单词 样例: 输入 When most kids go to school and study the knowledge, few special kids have made their history. A small boy from America wins the international contest by defeating adult competitors. He becomes the youngest winner. He has the gift and so many parents want to have such a kid. Though we are not that smart, we still can study hard to realize our dreams. 输出 a adult america and are becomes boy by can competitors contest defeating dreams few rom gift go hard has have he history international kid kids knowledge made many most not our p rents realize school small smart so special still study such that the their though to want we when winner wins youngest
代码
#include
#include
#include
#include
typedef struct Node{
char w[50];
struct Node* parent;
struct Node* lchild;
struct Node* rchild;
}BTree;
void binary_insert(BTree* T,BTree* w){
BTree* y =NULL;
BTree* x = T->lchild;
int res = 0;
while(x!=NULL){
y = x;
res = strcmp(w->w,x->w);
if(res>0){
x = x->rchild;
}
else if(reslchild;
}
else{
return;
}
}
w->parent=y;
if(y == NULL){
T->lchild=w;
}
else if(res>0){
y->rchild=w;
}
else if(reslchild=w;
}
}
//the order of dictionary
void inOrder(BTree* root){
if(root == NULL){
return;
}
else{
inOrder(root->lchild);
printf("%s\n",root->w);
inOrder(root->rchild);
}
}
int main(){
FILE* fp;
int c;
char word[50];
BTree T;
BTree* mid;
T.lchild=NULL;
int count = 0;
if( (fp = fopen("./article.txt","r"))==NULL){
puts("error");
exit(0);
}
int i=0;
while(!feof(fp)){
c = getc(fp);
if((c>= 65 && c=97 && c |