当前位置: 首页 > news >正文

泰安网站推广 泰安网站建设wordpress旅游模板下载

泰安网站推广 泰安网站建设,wordpress旅游模板下载,公司员工培训内容有哪些,怎么申请公司网站C语言构建定长字典 1.C语言简介-struct C语言中没有字典。而有些场合下需要统计一些字符串变量的累计值#xff0c;就需要用定长字典。定长字典顾名思义就是长度固定的字典。在C语言中结构体可以定义任意类型数据的集合#xff0c;也就可以通过结构体数组来构造个定长字典。…C语言构建定长字典 1.C语言简介-struct C语言中没有字典。而有些场合下需要统计一些字符串变量的累计值就需要用定长字典。定长字典顾名思义就是长度固定的字典。在C语言中结构体可以定义任意类型数据的集合也就可以通过结构体数组来构造个定长字典。 2.词频字典 2.1词频字典结构体 /* 词频字典结构体 */#define WORD_MAX_SIZE 100 struct word_fre_dict {char word[WORD_MAX_SIZE]; /* 假设单词长度最长为100 */int times; /* 在一篇文章出现次数不超过 2^31 - 1次 */ }; typedef struct word_fre_dict WORD_FRE_DICT; 2.2 词频字典的排序 /* 可以用qsort函数进行排序 *//* 按字典序排序 */ int cmp_dict(const void *a, const void *b) {WORD_FRE_DICT *pa (WORD_FRE_DICT *)a; WORD_FRE_DICT *pb (WORD_FRE_DICT *)b;return strcmp(pa-word, pb-word); } /* 按词频从小到大排序 */ int cmp_fre_up(const void *a, const void *b) {WORD_FRE_DICT *pa (WORD_FRE_DICT *)a; WORD_FRE_DICT *pb (WORD_FRE_DICT *)b;return (pa-times - pb-times); } /* 按词频从大到小排序 */ int cmp_fre_down(const void *a, const void *b) {WORD_FRE_DICT *pa (WORD_FRE_DICT *)a; WORD_FRE_DICT *pb (WORD_FRE_DICT *)b;return (pb-times - pa-times); }2.3 从字符串文本中提取词频字典 void create_word_fre_dict(char* paragraph) {WORD_FRE_DICT word_list[1000] { 0 };memset(word_list, 0, 1000 * sizeof(WORD_FRE_DICT));/* 预处理 单词全改为小写, 非单词全转为空格符 */int i 0;while (paragraph[i] ! 0) {if (paragraph[i] A paragraph[i] Z) {tolower(paragraph[i]);}else if ((paragraph[i] A || paragraph[i] Z) \((paragraph[i] a || paragraph[i] z))) {paragraph[i] ;}i;}/* 使用strtok公式进行字符串拆分 */char* temp strtok(paragraph, );strcpy(word_list[0].word, temp);word_list[0].times;while (temp ! NULL) {temp strtok(NULL, ); /* 最后一个字节拿出来后还会执行一次这次结果为NULL */if (temp NULL) {break;}printf(%s\n, temp);int dict_index 0;int find 0;while (word_list[dict_index].times ! 0 dict_index 1000) {if (strcmp(word_list[dict_index].word, temp) 0) {word_list[dict_index].times;find 1;break;}dict_index;}if (!find dict_index 1000) {strcpy(word_list[dict_index].word, temp);word_list[dict_index].times 1;}}qsort(word_list, 50, sizeof(WORD_FRE_DICT), cmp_dict);for (int de 0; de 20; de) {printf(%s, count %d\n, word_list[de].word, word_list[de].times);} }int c_dict_test(void) {char para[] { Youth means a temperamental predominance of courage over timidity, \of the appetite for adventure over the love of ease. This often \exits in a man of 60, more than a boy of 20.nobody grows merely \by the number of years; we grow old by deserting our ideas. Years \may wrinkle the skin, but to give up enthusiasm wrinkles the soul. \Worry, fear, self distrust bows the heart and turns the spirit \back to dust. };printf(%s\n, para);create_word_fre_dict(para);return 0; }
http://www.pierceye.com/news/751627/

相关文章:

  • 网站在线交谈wordpress信息填写
  • 服饰网站建设微网站建设 合同
  • dede网站 远程生成wordpress后台不能登陆
  • word如何做网站链接湖南省绿色建筑信息平台
  • v9网站模板网站建设六道
  • php网站开发原理企业门户网站费用
  • 白银市建设管理处网站定制网站建设和运营
  • 免费音乐网站建设新闻资讯建站服务商
  • 佛山市建设企业网站服务机构普通网站建设计入什么科目
  • 阿里虚拟机建设网站网络科技有限公司营业执照
  • 如何申请建设网站首页培训机构怎么做线上推广
  • 网站维护升级访问中做网站工单
  • 如何用ae做模板下载网站电脑网站建设规划
  • 北京京水建设集团有限公司网站西青做网站
  • 自己建的网站可以用笔记本做服务器吗网站建设后台系统有哪些
  • 做的asp网站手机号码网站开发软件手机版
  • android 做电子书下载网站网络热词作文
  • 网络网站销售龙岩建筑网
  • 专门找事做的网站iis7 wordpress伪静态规则
  • 做字体的网站济宁网站建设 济宁智雅
  • 工程门户网站建设怎样制作表白网站
  • 手机如何创建个人网站上海 .net网站建设
  • 小程序app软件定制开发首页排名优化公司
  • 红酒 专业 网站建设视频网站后台
  • 宁波网站建设58同城百度突然搜不到网站
  • 网站开发技术和seo的联系wordpress发邮件卡主
  • 网站开发安全模块方案网站运营方案怎么写?
  • 章丘网站制作手机网站 微信平台
  • 自定义功能的网站做坏事网站
  • 做农村电子商务的网站有哪些wordpress批量修改引用网址