C语言,单词排序,将一篇英语文章出现的单词去掉重复的,并按字母顺序排列
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/27 23:24:26
C语言,单词排序,将一篇英语文章出现的单词去掉重复的,并按字母顺序排列
如:Six hundred years ago,Sir Johan Hawkwood arrived in Italy with a band of soldiers and settled near Florence..
按字母顺序排列:
a ago and arrived band Florence Hawkwood hundred in Italy Johan near of settled Sir Six soldiers with years
注意大写字母开头的也要正确排序
如:Six hundred years ago,Sir Johan Hawkwood arrived in Italy with a band of soldiers and settled near Florence..
按字母顺序排列:
a ago and arrived band Florence Hawkwood hundred in Italy Johan near of settled Sir Six soldiers with years
注意大写字母开头的也要正确排序
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(void)
{
char *b = "Six hundred years ago, Sir Johan Hawkwood arrived in Italy with a band of soldiers and settled near Florence.";
char a[100][20] = {'\0'};
char temp[20],temp1[20],temp2[20];
int i, j, k;
for (i=0,j=0,k=0; b[i]!='\0'; i++)
{
if(b[i] != ' '&& !ispunct(b[i]))
{
a[j][k] = b[i];
k++;
}
else
{
j++;
k=0;
}
}
for (i=0; i<=j; i++)
{
for (k=i+1; k<=j; k++)
{
strcpy(temp1, a[i]);
*temp1 = tolower(*temp1);
strcpy(temp2, a[k]);
*temp2 = tolower(*temp2);
if (strcmp(temp1, temp2) == 1)
{
strcpy(temp, a[i]);
strcpy(a[i], a[k]);
strcpy(a[k], temp);
}
else if (strcmp(temp1, temp2) == 0)
{
a[k][0] = '\0';
k++;
}
}
if(a[i][0] != '\0')
printf("%s ", a[i]);
}
}
C语言,单词排序,将一篇英语文章出现的单词去掉重复的,并按字母顺序排列
如何统计一篇英语文章单词重复出现的次数?
怎么用C语言实现从文件中读取一段英文文章,将里面的字母,空格的个数显示出来,并将单词排序;就是大写和小写字母也要区别
C语言字母排序问题输入n个字符串,将他们按字母由小到大的顺序排列并输出我只学过基础的C,指针什么的不会,还有请附带详细点
将下列单词按英语字典中出现的先后顺序排列:
按字母顺序排列的初中英语单词
C语言:统计一篇英文文章中所要查询单词出现的次数以及出现的位置
将所给字母重新排序,组成正确的单词,并写出中文.
将所给的字母重新排序组成单词,并写出中文
JAVA统计一篇文章中所有单词出现的次数,并按字典序将单词及频数输出到文件中
将下列单词按照字典中出现的先后顺序排列
按正确的顺序排列单词并填空