急求C语言数据结构课程设计!!!!!

各位高手,小弟急求一份课程设计,题目是:编写一个基数排序算法,将一组英文单词按字典序排序,设最长的单词有n个字母。并且可查找到指定单词。谁知道请伸出援助之手,帮在下一把,... 各位高手,小弟急求一份课程设计,题目是:编写一个基数排序算法,将一组英文单词按字典序排序,设最长的单词有n个字母。并且可查找到指定单词。谁知道请伸出援助之手,帮在下一把,先谢谢了!!! 展开
 我来答
tjw408797664
2009-12-14 · TA获得超过1153个赞
知道小有建树答主
回答量:1042
采纳率:0%
帮助的人:747万
展开全部
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ML 500

struct node
{
char data[50];
struct node *lc,*rc;
};

char article[]={"Explosives, as we all know ,are things that can't get close to.Though it dosen't sound good,it plays an important part in our world.Nowadays ,almost everthing,is made using electricity.And coal is the most important resource to make electricity.Needless to say ,metal is taken from rocks.Regardless of coal or metal,we have to use explosives to get them.In a word,if we did't have explosives,we wouldn't have such a modern world."};
int offset=0;
struct node *tree,*root;

void inorder(struct node *ctree)
{
if(ctree->lc!=NULL)inorder(ctree->lc);
printf("%s ",ctree->data);
if(ctree->rc!=NULL)inorder(ctree->rc);
}

void AddIn(char word[])
{
int i=0,k; tree=root;
while(1)
{
i=0;k=strcmp(word,tree->data);
if(k<0)
{
if(tree->lc==NULL)
{
tree->lc=(struct node*)malloc(sizeof(struct node));
do
tree->lc->data[i]=word[i];
while(word[i++]!=0);
tree->lc->lc=NULL;tree->lc->rc=NULL;
break;
}
else tree=tree->lc;
}
else if(k>0)
{
if(tree->rc==NULL)
{
tree->rc=(struct node*)malloc(sizeof(struct node));
do
tree->rc->data[i]=word[i];
while(word[i++]!=0);
tree->rc->lc=NULL;tree->rc->rc=NULL;
break;
}
else tree=tree->rc;
}
else break;
}
}

void GetAWord(char temp[])
{
int i=0;
while((article[offset]<'A')|((article[offset]>'Z')&&(article[offset]<'a'))|(article[offset]>'z')&&article[offset]!=0)offset++;
while((article[offset]>='A')&&(article[offset]<='Z')|(article[offset]>='a')&&(article[offset]<='z'))
if (article[offset]!=0)
{
if((article[offset]>='A')&&(article[offset]<='Z'))
temp[i]=article[offset]+'a'-'A' ;
else temp[i]=article[offset];
i++;offset++;
}
else break;
temp[i]=0;
}

void main()
{
char word[500];int i=0;

root=(struct node *)malloc(sizeof(struct node));
root->lc=NULL;root->rc=NULL;
GetAWord(word);
do
root->data[i]=word[i];
while(word[i++]!=0);
while(1)
{
GetAWord(word);
if(word[0]==0)break;
AddIn(word);
}
inorder(root);

}
pfdhi
2009-12-12 · TA获得超过239个赞
知道小有建树答主
回答量:360
采纳率:100%
帮助的人:225万
展开全部
再找找吧
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式