跪求三道C语言的编程题解答

来源:百度知道 编辑:UC知道 时间:2024/09/28 11:26:48
小弟急需这三道编程题的答案,请求各位高手大大帮忙解下,跪谢啦!
运用所学的C语言知识,编制和调试程序,具有如下功能:
(1)对存储在chapter.dat文件中的英文文章进行下面的处理操作,文章的具体内容自己输入。

(2)统计各个单词的数量,并将单词排序,排序结果输出到out.dat中,格式如下:
单词名 数量

(3)输入某一单词,判断该单词是否存在于该文章中,若存在,指出其在文章中出现的次数。

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char str[20],ch,*p;
FILE *fp;
typedef struct Rec
{
char str[20];
int num;
struct Rec *next;
}Rec;
Rec head,*pp,*news;

int get_ch()
{
ch='0';
ch=fgetc(fp);
if(ch>='a'&&ch<='z' || ch>='A'&&ch<='Z')return 1;
if(feof(fp))return -1;
return 0;
}
void record()
{
if(head.next==NULL)
{
head.next=(Rec*)malloc(sizeof(Rec));
head.next->next=NULL;
strcpy(head.next->str,str);
head.next->num=1;
}
else
{
pp=&head;
while(pp->next)
{
if(strcmp(pp->next->str,str)==0)
{
pp->next->num++;
return;
}
else
{
if(strcmp(pp->next->str,str)>0)
{