finish tests of lab26

This commit is contained in:
Kaehvaman 2024-12-06 20:08:12 +04:00
parent 803a4b2e9e
commit e0f63df0c8
13 changed files with 73 additions and 16 deletions

Binary file not shown.

View File

@ -1,6 +1,6 @@
#pragma once
#define DICT_ARRAY_C
#define DICT_TREE_C
/*
Основные операции СЛОВАРЯ:

View File

@ -1,21 +1,26 @@
//
// Реализация словаря на хэше
//
#ifdef DICT_HASH_C
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdlib.h>
#include "Dict.h"
#include "fnvhash_32a.h"
#include "jhash.h"
#define MAX_HASH 13267
#ifdef DICT_HASH_C
struct Node {
char* word;
struct Node* next;
};
#define FNV_HASH
#if defined VLASENKO_HASH
#define MAX_HASH 13267
// Массив списков
struct Node* first[MAX_HASH];
@ -30,6 +35,31 @@ int hash(char* word) {
return hash_value % MAX_HASH;
}
#elif defined JHASH
#define MAX_HASH 16384
// Ìàññèâ ñïèñêîâ
struct Node* first[MAX_HASH];
int hash(char* word) {
int hash_value = (int)jhash(word, strlen(word) + 1, FNV1_32A_INIT);
hash_value = hash_value & hashmask(14);
}
#elif defined FNV_HASH
#define MAX_HASH 16384
// Ìàññèâ ñïèñêîâ
struct Node* first[MAX_HASH];
int hash(char* word) {
int hash_value = (int)fnv_32a_str(word, FNV1_32A_INIT);
hash_value = TINY_FNV(14, hash_value);
}
#endif
/* INSERT добавляет элемент в множество.
Множество содержит только уникальные элементы.
При повторном добавлении элемента в множество, множество не изменяется.

View File

@ -1,5 +1,3 @@
#ifdef DICT_LINKED_LIST_C
//
// Реализация АТД «Словарь» на Структуре данных «Односвязанный список»
//
@ -9,6 +7,7 @@
#include "Dict.h"
#ifdef DICT_LINKED_LIST_C
// элемент односвязанного списка
struct Node {

View File

@ -1,9 +1,10 @@
#ifdef DICT_SORTED_ARRAY_C
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdlib.h>
#include "Dict.h"
#ifdef DICT_SORTED_ARRAY_C
#define MAX_WORDS 10000
// Ñëîâà
@ -48,6 +49,15 @@ MEMBER
*/
int Member(char* word) {
// Èñïîëüçóåòñÿ àëãîðèòì áèíàðíîãî ïîèñêà ñëîâà â îòñîðòèðîâàííîì ìàññèâå
if (bsearch(word, words, numWords, sizeof(char), strcmp)) {
return 1;
}
else {
return 0;
}
/*
int left = 0;
int right = numWords - 1;
@ -65,7 +75,7 @@ int Member(char* word) {
right = middle - 1;
}
}
return 0;
return 0;*/
}
#endif

View File

@ -2,13 +2,13 @@
// Ðåàëèçàöèÿ ñëîâàðÿ íà äâîè÷íîì äåðåâå ïîèñêà
//
#ifdef DICT_TREE_C
#define _CRT_SECURE_NO_WARNINGS
#include <string.h>
#include <stdlib.h>
#include "Dict.h"
#ifdef DICT_TREE_C
// Óçåë äåðåâà
struct NodeTree {
char* word;

View File

@ -119,7 +119,7 @@ int TextProcessing(char* filenameIn, char* filenameOut) {
fprintf(fout, "<!DOCTYPE html>");
fprintf(fout, "<html>");
fprintf(fout, "<head>");
fprintf(fout, "<meta http-equiv = \"Content-Type\" content = \"text/html; charset=ñç1251\" />");
fprintf(fout, "<meta http-equiv = \"Content-Type\" content = \"text/html; charset=cp1251\" />");
fprintf(fout, "<title>HTML Document</title>");
fprintf(fout, "</head>");
fprintf(fout, "<body>");

View File

@ -104,10 +104,12 @@
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<AdditionalIncludeDirectories>..\..\hash functions</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<StackReserveSize>4194304</StackReserveSize>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -127,6 +129,8 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\hash functions\fnvhash_32a.c" />
<ClCompile Include="..\..\hash functions\jhash.c" />
<ClCompile Include="DictArray.c" />
<ClCompile Include="DictHash.c" />
<ClCompile Include="DictLinkedList.c" />
@ -135,6 +139,8 @@
<ClCompile Include="TextProcessing.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\hash functions\fnvhash_32a.h" />
<ClInclude Include="..\..\hash functions\jhash.h" />
<ClInclude Include="Dict.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@ -33,10 +33,22 @@
<ClCompile Include="DictArray.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="..\..\hash functions\fnvhash_32a.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="..\..\hash functions\jhash.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Dict.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="..\..\hash functions\fnvhash_32a.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
<ClInclude Include="..\..\hash functions\jhash.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><meta http-equiv = "Content-Type" content = "text/html; charset=ñç1251" /><title>HTML Document</title></head><body>Alice'<b>s</b> Adventures <b>in</b> Wonderland<br>
<!DOCTYPE html><html><head><meta http-equiv = "Content-Type" content = "text/html; charset=cp1251" /><title>HTML Document</title></head><body>Alice'<b>s</b> Adventures <b>in</b> Wonderland<br>
Lewis Carroll<br>
<br>
<br>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><meta http-equiv = "Content-Type" content = "text/html; charset=ñç1251" /><title>HTML Document</title></head><body><b>The</b> <b>Fellowship</b> <b>of</b> <b>the</b> <b>Ring</b><br>
<!DOCTYPE html><html><head><meta http-equiv = "Content-Type" content = "text/html; charset=cp1251" /><title>HTML Document</title></head><body><b>The</b> <b>Fellowship</b> <b>of</b> <b>the</b> <b>Ring</b><br>
<b>J</b>. <b>R</b>. <b>R</b>. <b>Tolkien</b><br>
<br>
<br>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html><html><head><meta http-equiv = "Content-Type" content = "text/html; charset=ñç1251" /><title>HTML Document</title></head><body><b>The</b> <b>Fellowship</b> <b>of</b> <b>the</b> <b>Ring</b><br>
<!DOCTYPE html><html><head><meta http-equiv = "Content-Type" content = "text/html; charset=cp1251" /><title>HTML Document</title></head><body><b>The</b> <b>Fellowship</b> <b>of</b> <b>the</b> <b>Ring</b><br>
<b>J</b>. <b>R</b>. <b>R</b>. <b>Tolkien</b><br>
<br>
<br>