作业帮 > 综合 > 作业

提取英文句子中的单词并排序输出 c语言

来源:学生作业帮 编辑:百度作业网作业帮 分类:综合作业 时间:2024/04/29 20:01:54
提取英文句子中的单词并排序输出 c语言
写一个分词函数,提取出一个英文句子中的所有单词,保存到一个单词数组中.另写一个排序函数对字符串数组进行升序排序.在主函数中调用分词函数得到单词数组,调用排序函数对单词排序,然后在主函数中输出各单词.注意:只允许在//
}
提取英文句子中的单词并排序输出 c语言
#include <stdio.h>
#include <string.h>

int GetWords(char *sentence, char *words[]);
void SortStrings( char *strs[],int count);

int main()
{
char str[200];
int nWords = 0;
char *words[20];
int i;

printf("input a string: ");
gets(str);
nWords = GetWords(str, words);
SortStrings(words,nWords);
puts("output:");
for(i=0; i<nWords; i++)
{
puts(words[i]);
}
return 0;
}
int GetWords(char *sentence,char *words[])
{
//
}