资源简介
数据结构相关的课程设计,实现了基于顺序表、链表、二叉树、哈希表的词频统计与检索,仅供参考!

代码片段和文件信息
// 实习.cpp : 定义控制台应用程序的入口点。
//
#include “stdafx.h“
#include
#include
#include
#include
#include
#include
#include “malloc.h“
#include “stdlib.h“
#include
#include
#include
using namespace std;
typedef struct
{
string words;//储存单词
int count;//记录单词个数后面出现几次
}sq;
int n=0a;
string word[500];
sq p[5000];
int tr=0total=0mi=0;
void readtxt()
{char letter[24];
int K;
FILE *fp;
char ch;
fp=fopen(“D://InFile.txt““r“);//读取文件,需改为你要读取的文件的绝对路径
while (!feof(fp))//feof()检测是否达到文件尾部
{ch = getc(fp);//获取当前字符
if (ch == ‘ ‘ || ch == 10)
{//ASCLL码中10为换行符,此条件为遇到空格或换行则跳过
continue;
}
if ((ch >= ‘a‘&&ch <= ‘z‘) || (ch >= ‘A‘&&ch <= ‘Z‘)) //发现一个单词
{
K = 0;
while ((ch >= ‘a‘&&ch <= ‘z‘) || (ch >= ‘A‘&&ch <= ‘Z‘) || (ch == ‘\‘‘))
{
if (ch >= ‘A‘&&ch <= ‘Z‘)
ch += 32;//转换成小写
letter[K++] = ch;//把当前字母存入数组
ch = getc(fp);
}
letter[K++] = ‘\0‘;//结束标志\0
word[n]=letter;
//cout< n++;
}}
}
void time(){
LARGE_INTEGER litmp;
LONGLONG QPart1QPart2;
double dfMinusdfFreqdfTim;
QueryPerformanceFrequency(&litmp);
dfFreq = (double)litmp.QuadPart;
QueryPerformanceCounter(&litmp);
QPart1 = litmp.QuadPart;
Sleep(100) ;
QueryPerformanceCounter(&litmp);
QPart2 = litmp.QuadPart;
dfMinus = (double)(QPart2-QPart1);
dfTim = dfMinus/dfFreq;
dfTim*=1000000;
printf(“查找该单词所用的时间:%lf 微秒\n“dfTim);}
typedef struct
{sq * elem;
int length;
}sqlist;
int partition(sqlist &Lint low int high)
{string pivotkey;
L.elem [0]=L.elem [low];
pivotkey=L.elem [0].words;
while(low {
while(lowpivotkey) --high;
L.elem [low]=L.elem [high];
while(low L.elem [high]=L.elem [low];
}
L.elem [low]=L.elem [0];
return low;
}
void qsort(sqlist &Lint lowint high)
{int pivotloc;
if(low pivotloc=partition(Llowhigh);
qsort(Llowpivotloc-1);
qsort(Lpivotloc+1high);
}
}
void quicksort(sqlist &L)
{
qsort(L1L.length-1);
}
void sortdata(sq s[])
{
sq e;
int t=0pji;
while(t {
p=a;
for (i = 0; i {
if (word[t] ==s[i].words )//如果有单词相同
{
s[i].count ++;//则此类单词加1
break;//进行下一个单词的查找
}
}
if (a == 0 || i == a)//前面如果没有相同的单词
{
s [a].words =word[t] ;//给此单词分配位置
s[a].count =1 ;
a++;}
t++;}
for (j = 0; j
for (i = 0; i
if (s[i].words >s[i + 1].words )
{
e = s[i];
s[i] = s[i + 1];
s[i + 1] =e;
}
}
void sqsave(sqlist &L)
{int it=0f=1jpq=1;
L.elem=new sq[5000];
if(!L.elem)exit(0);
L.length =0;
while(t {
p=f;
for (i = 1; i {
if (word[t] ==L.elem [i].words )//如果有单词相同
{
L.elem [i].count ++;//则此类单词加1
break;
}
}
if (f == 1 || i == f)/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 19129 2016-12-30 11:37 实习.cpp
文件 26112 2017-11-13 16:11 实习报告书.doc
相关资源
- 数据结构年终考题范围和答案 耿国华
- 数据结构 朱战力 习题解答 数据结构
- 数据结构课程设计 6 1 彩票系统
- 教学计划编制系统
- 大数(链表、数组)实现
- 自己写的航空订票系统c 版--数据结构
- 数据结构实验魔王语言
- 航空订票系统_数据结构课程设计
- 多项式求和(数据结构C 版)
- 尚观培训linux董亮老师关于数据结构的
- 数据结构 知识点总结
- 华南理工大学数据结构复习提纲二
- 华南理工大学数据结构复习提纲一
- 数据结构用C 写的停车场系统源代码
- 数据结构(河北科技大学)
- 数据结构考前习题 清华大学出版社
- 数据结构课件(北邮)
- 数据结构实验 基于栈的表达式求值
- 数据结构课程设计——图书管理系统
- 成绩管理系统(数据结构)
- 数据结构-最小通信网问题
- 数据结构课程设计同学通讯录系统
- DICOM文件读取程序
- 数据结构课程设计 公园导游图
- 数据结构殷人昆版的课后答案
- bmp文件读出为txt文件 txt文件写入为
- 2006年湖北工业大学409数据结构试题
- 数据结构实验-魔王语言-源码加实验报
- 简单计算器的实现(数据结构)
- 简单计算器的实现(数据结构 修正版
评论
共有 条评论