题目描述:打开一个英文文本文件,假设文本文件单词之间全部用“空格”隔开,文本各段之间用“回车符”分开,统计输出文本的段数量,总单词数量,以及文本段的最长、最短、平均单词数量。
test.txt 文本内容:随便百度的内容
C语言代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>#define MAX_LINE 1024
void main(){
//duanluo 表示段落数,words表示某一段的单词数
int duanluo = 0, words = 0;
//min表示最小段落的单词数,max:最大段落的单词数,sum:单词总数
int min = 65525, ave = 0, max = 0,sum = 0;
FILE* fp; //文件指针
char buffer[MAX_LINE] ; //缓冲区
int len ; //行字符个数
int i;
fp = fopen("test.txt","r");
if(fp &#