return0;
}
2.4【测试及运行结果】
2.5【总结】
这个的关键点在于字符必须减去‘0’才可以进行运算。
题目三文本文件单词统计
3.1【问题描述】
假设有如下的英文文本文档:
(此处为太原理工大学学校简介英文版)
TAIYUANUNIVERSITYOFTECHNOLOGY
TaiyuanUniversityofTechnology(TUT)hasitshistorytracedallthewaybacktotheWesternLearningSchoolof
ShanxiGrandAcademy(1902),whichwasoneofthethreeearliestnationaluniversitiesinChina.Withthetraditionand
developmentofover100years,TUTisnowageneraluniversitywithengineeringasthemajor,sciencesandtechnology
integratedandcoordinatedevelopmentofmultipledisciplines.Itisauniversitythatisincludedinthe“Project211”---
thenationalhighereducationpromotionprogramfor100topuniversitiesinChina.
……
Recollectingthecentennialhistory,generationsofTUThavecreateditsmissionandgloryofacenturywithresponsibility
andconfidence;expectingthepromisingtomorrow,over30,000TUTstudentsandfacultyareproducingsplendorand
perspectivesbytheirwisdomanddiligence.Inthenewera,TaiyuanUniversityofTechnology,followingtheConception
ofScientificDevelopment,isdeterminedtofurtherthereformationoneducation,toreinforcetheteachingmanagementso
astoupgradeitsteachingandresearchinglevels.TaiyuanUniversityofTechnologywillbeturningitselfintoa
research-baseduniversity.
设计C或C++程序,统计在这样的英文文本文件中,出现了多少个单词,每个单词出现了几
次。
连续的英文字符都认为单词(不包括数字),单词之间用空格或标点符号分隔。
3.2【设计及分析】
要统计英文文本文件中出现了哪些单词,就要从文件中读取字符,读取出来的连续英文字符
认为是一个单词,遇空格或标点符号单词结束。
使用线性表记录单词以及每个单词出现的次数。
线性表中的单词按字典顺序存储。
线性表的顺序存储结构如下:
#defineLIST_INIT_SIZE100//线性表存储空间的初始分配量
#defineLISTINCREMENT10//线性表存储空间的分配增量
typedefstruct{
charword[21]//存储单词,不超过20个字符
i