91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡(jiǎn)介

數(shù)據(jù)結(jié)構(gòu)相關(guān)的課程設(shè)計(jì),實(shí)現(xiàn)了基于順序表、鏈表、二叉樹(shù)、哈希表的詞頻統(tǒng)計(jì)與檢索,僅供參考!

資源截圖

代碼片段和文件信息

//?實(shí)習(xí).cpp?:?定義控制臺(tái)應(yīng)用程序的入口點(diǎn)。
//
#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;//儲(chǔ)存單詞
int?count;//記錄單詞個(gè)數(shù)后面出現(xiàn)幾次

}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“);//讀取文件,需改為你要讀取的文件的絕對(duì)路徑

while?(!feof(fp))//feof()檢測(cè)是否達(dá)到文件尾部

{ch?=?getc(fp);//獲取當(dāng)前字符

if?(ch?==?‘?‘?||?ch?==?10)

{//ASCLL碼中10為換行符,此條件為遇到空格或換行則跳過(guò)

continue;

}

if?((ch?>=?‘a(chǎn)‘&&ch?<=?‘z‘)?||?(ch?>=?‘A‘&&ch?<=?‘Z‘))??????????????//發(fā)現(xiàn)一個(gè)單詞

{

K?=?0;?



while?((ch?>=?‘a(chǎn)‘&&ch?<=?‘z‘)?||?(ch?>=?‘A‘&&ch?<=?‘Z‘)?||?(ch?==?‘\‘‘))

{

if?(ch?>=?‘A‘&&ch?<=?‘Z‘)

ch?+=?32;//轉(zhuǎn)換成小寫

letter[K++]?=?ch;//把當(dāng)前字母存入數(shù)組

ch?=?getc(fp);

}
letter[K++]?=?‘\0‘;//結(jié)束標(biāo)志\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(“查找該單詞所用的時(shí)間:%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;//進(jìn)行下一個(gè)單詞的查找
}
}

????if?(a?==?0?||?i?==?a)//前面如果沒(méi)有相同的單詞
????{
?????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)/

?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????19129??2016-12-30?11:37??實(shí)習(xí).cpp
?????文件???????26112??2017-11-13?16:11??實(shí)習(xí)報(bào)告書.doc

評(píng)論

共有 條評(píng)論

相關(guān)資源