diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.sln" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.sln" new file mode 100644 index 0000000..003894e --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31410.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FrequencyOfOccurrenceOfWords", "FrequencyOfOccurrenceOfWords\FrequencyOfOccurrenceOfWords.vcxproj", "{ECBF2784-C770-44C8-A208-31046468F94E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x64.ActiveCfg = Debug|x64 + {ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x64.Build.0 = Debug|x64 + {ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x86.ActiveCfg = Debug|Win32 + {ECBF2784-C770-44C8-A208-31046468F94E}.Debug|x86.Build.0 = Debug|Win32 + {ECBF2784-C770-44C8-A208-31046468F94E}.Release|x64.ActiveCfg = Release|x64 + {ECBF2784-C770-44C8-A208-31046468F94E}.Release|x64.Build.0 = Release|x64 + {ECBF2784-C770-44C8-A208-31046468F94E}.Release|x86.ActiveCfg = Release|Win32 + {ECBF2784-C770-44C8-A208-31046468F94E}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {DD9F0B46-CB0B-4502-8346-C982FBFEB6C1} + EndGlobalSection +EndGlobal diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.c" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.c" new file mode 100644 index 0000000..207c694 --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.c" @@ -0,0 +1,28 @@ +#include "ReadFile.h" +#include "TestReadFileUsingHashTable.h" +#include + +int main() +{ + if (!testReadFileUsingHashTable()) + { + return -1; + } + Error error = NOT_ERROR; + HashTable* table = createTable(&error, 1); + int result = readFile(&table, "Text.txt"); + if (result == -1) + { + deleteHashTable(table); + printf("File not found"); + return -1; + } + if (error == INSUFFICIENT_MEMORY) + { + deleteHashTable(table); + printf("Memory not allocated"); + return -1; + } + printValue(table); + deleteHashTable(table); +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.vcxproj" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.vcxproj" new file mode 100644 index 0000000..555090a --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.vcxproj" @@ -0,0 +1,157 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {ecbf2784-c770-44c8-a208-31046468f94e} + FrequencyOfOccurrenceOfWords + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.vcxproj.filters" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.vcxproj.filters" new file mode 100644 index 0000000..5f60d17 --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords.vcxproj.filters" @@ -0,0 +1,48 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + \ No newline at end of file diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/ReadFile.c" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/ReadFile.c" new file mode 100644 index 0000000..e76b231 --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/ReadFile.c" @@ -0,0 +1,27 @@ +#include +#include "ReadFile.h" + +int readFile(HashTable** table, const char* fileName) +{ + FILE* file = fopen(fileName, "r"); + if (file == NULL) + { + return -1; + } + while (!feof(file)) + { + // words in the file are less than 100 characters in size + char array[100] = { '\0' }; + Error error = NOT_ERROR; + if (fscanf(file, "%s", array) != EOF) + { + addElement(array, table, &error); + if (error == INSUFFICIENT_MEMORY) + { + return -2; + } + } + } + fclose(file); + return 0; +} diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/ReadFile.h" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/ReadFile.h" new file mode 100644 index 0000000..0864cbd --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/ReadFile.h" @@ -0,0 +1,5 @@ +#pragma once +#include "../../HashTable/HashTable/HashTable.h" + +// Function for reading a file +int readFile(HashTable** table, const char* fileName); diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/Test.txt" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/Test.txt" new file mode 100644 index 0000000..295de45 --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/Test.txt" @@ -0,0 +1 @@ +Hello World S Hello Hello S World Test Commit A S \ No newline at end of file diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/TestReadFileUsingHashTable.c" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/TestReadFileUsingHashTable.c" new file mode 100644 index 0000000..fbd35de --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/TestReadFileUsingHashTable.c" @@ -0,0 +1,28 @@ +#include "TestReadFileUsingHashTable.h" +#include "ReadFile.h" + +bool testReadFileUsingHashTable() +{ + Error error = NOT_ERROR; + HashTable* table = createTable(&error, 100); + int result = readFile(&table, "Test.txt"); + if (result == -1) + { + deleteHashTable(table); + return false; + } + if (error == INSUFFICIENT_MEMORY) + { + deleteHashTable(table); + return false; + } + const int firstCheck = countNumberOfDuplicateItemsForSpecificList("Hello", table); + const int secondCheck = countNumberOfDuplicateItemsForSpecificList("World", table); + const int thirdCheck = countNumberOfDuplicateItemsForSpecificList("Test", table); + const int fourthCheck = countNumberOfDuplicateItemsForSpecificList("Commit", table); + const int fifthCheck = countNumberOfDuplicateItemsForSpecificList("A", table); + const int sixthCheck = countNumberOfDuplicateItemsForSpecificList("S", table); + deleteHashTable(table); + return firstCheck == 3 && secondCheck == 2 && thirdCheck == 1 + && fourthCheck == 1 && fifthCheck == 1 && sixthCheck == 3; +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/TestReadFileUsingHashTable.h" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/TestReadFileUsingHashTable.h" new file mode 100644 index 0000000..ffa3433 --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/TestReadFileUsingHashTable.h" @@ -0,0 +1,5 @@ +#pragma once +#include + +// Function for checking the counting of words in the text +bool testReadFileUsingHashTable(); \ No newline at end of file diff --git "a/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/Text.txt" "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/Text.txt" new file mode 100644 index 0000000..7358f51 --- /dev/null +++ "b/Homework \342\204\226 9/FrequencyOfOccurrenceOfWords/FrequencyOfOccurrenceOfWords/Text.txt" @@ -0,0 +1 @@ +of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herbof the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb vvof the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb vvof the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb of the surface of the right-hand wall. Winston turned a switch and the voice sank somewhat, though the words were still distinguishable. The instrument (the telescreen, it was called) could be dimmed, but there was no way of shutting it off completely. He moved over to the window: a smallish, frail figure, the meagreness of his body merely emphasized by the blue overalls which were the uniform of the party. His hair was very fair, his face naturally sanguine, his skin roughened by coarse soap and blunt razor blades and the cold of the winter that had just ended. Outside, even through the shut window-pane, the world looked cold. Down in the street little eddies of wind were whirling dust and torn paper into spirals, and though the sun was shining and the sky a harsh blue, there seemed to be no colour in anything, except the posters that were plastered everywhere. The black-moustachio’d face gazed down from every commanding corner. There was one on the house-front immediately opposite. BIG BROTHER IS WATCHING YOU, the caption said, while the dark eyes looked deep into Winston’s own. Down at street level another poster, torn at one corner, flapped fitfully in the wind, alternately covering and uncovering the single word INGSOC. In the far distance a helicopter skimmed down between the roofs, hovered for an instant like a bluebottle, and darted away again with a curving flight. It was the police patrol, snooping into people’s windows. The patrols did not matter, however. Only the Thought Police mattered.Behind Winston’s back the voice from the telescreen was still babbling away about pig-iron and the overfulfilment of the Nith Three-Year Plan. The telescreen received and transmitted simultaneously. Any sound that Winston made, above the level of a very low whisper, would be picked up by it, moreover, so long as he remained within the field of vision which the metal plaque commanded, he could be seen as well as heard. There was of course no way of knowing whether you were being watched at any given moment. How often, or on what system, the Thought Police plugged in on any individual wire was guesswork. It was even conceivable that they watched everybody all the time. But at any rate they could plug in your wire whenever they wanted to. You had to live – did live, from habit that became instinct – in the assumption that every sound you made was overheard, and, except in darkness, every movement scrutinized.reg grgrgregreg ergregre fefefefefeif fewfeireier rrmfeifme grgoerigmreig gregrogmr grekgrggreignr rigmrmigmr rgmrgmrgimr rgmirgirmgmr grmirimgrmig rmgrigmirgmir rmgrigmrigrimg grigrmigrmg mrgrigrmigmig gr9gkrk9rg9kg9k gk9r9gkr9gk9gr vjvjvjirj rgorirk rereverivbreijvriv their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb their crazy garden walls sagging in all directions? And the bombed sites where the plaster dust swirled in the air and the willow-herb diff --git "a/Homework \342\204\226 9/HashTable/HashTable.sln" "b/Homework \342\204\226 9/HashTable/HashTable.sln" new file mode 100644 index 0000000..0faf154 --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31410.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HashTable", "HashTable\HashTable.vcxproj", "{7F515015-3F19-4A2A-9F71-2B4E17988297}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x64.ActiveCfg = Debug|x64 + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x64.Build.0 = Debug|x64 + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x86.ActiveCfg = Debug|Win32 + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Debug|x86.Build.0 = Debug|Win32 + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x64.ActiveCfg = Release|x64 + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x64.Build.0 = Release|x64 + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x86.ActiveCfg = Release|Win32 + {7F515015-3F19-4A2A-9F71-2B4E17988297}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {4E72E434-3C39-4E83-A4CF-8341EC15AAA4} + EndGlobalSection +EndGlobal diff --git "a/Homework \342\204\226 9/HashTable/HashTable/HashTable.c" "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.c" new file mode 100644 index 0000000..e253802 --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.c" @@ -0,0 +1,149 @@ +#include "HashTable.h" +#include +#include +#include + +typedef struct HashTable +{ + int numberOfElements; + int numberOfSegment; + struct List** array; +} HashTable; + +HashTable* createTable(Error* error, int numberOfSegment) +{ + if (*error != NOT_ERROR) + { + return NULL; + } + HashTable* table = calloc(1, sizeof(HashTable)); + if (table == NULL) + { + *error = INSUFFICIENT_MEMORY; + return NULL; + } + table->numberOfSegment = numberOfSegment; + table->array = calloc(numberOfSegment, sizeof(List*)); + if (table->array == NULL) + { + free(table); + *error = INSUFFICIENT_MEMORY; + return NULL; + } + for (int i = 0; i < numberOfSegment; i++) + { + table->array[i] = createList(error); + if (*error != NOT_ERROR) + { + break; + } + } + return table; +} + +void deleteHashTable(HashTable* table) +{ + for (int i = 0; i < table->numberOfSegment; i++) + { + deleteList(table->array[i]); + } + free(table->array); + free(table); +} + +int hashFunction(const char* string, HashTable* table) +{ + int result = 0; + for (int i = 0; string[i] != '\0'; i++) + { + result = (result + string[i]) % table->numberOfSegment; + } + return abs(result); +} + +HashTable* resize(HashTable* table, Error* error) +{ + if (*error != NOT_ERROR) + { + return table; + } + HashTable* newTable = createTable(error, table->numberOfSegment * 2); + int i = 0; + while (i < table->numberOfSegment) + { + while (!isEmpty(table->array[i])) + { + add(newTable->array[hashFunction(getHeadValue(table->array[i]), table)], getHeadValue(table->array[i]), error); + *error = NOT_ERROR; + removeFirstElement(table->array[i], error); + } + deleteList(table->array[i]); + i++; + } + newTable->numberOfElements = table->numberOfElements; + free(table->array); + free(table); + return newTable; +} + +void addElement(const char* string, HashTable** table, Error* error) +{ + if (*error != NOT_ERROR) + { + return; + } + float factor = (float)((*table)->numberOfElements) / (float)((*table)->numberOfSegment); + if (factor > 1) + { + *table = resize(*table, error); + if (*error != NOT_ERROR) + { + return; + } + } + add((*table)->array[hashFunction(string, *table)], string, error); + if (*error == INSUFFICIENT_MEMORY) + { + return; + } + if (*error != ELEMENT_REPEATS) + { + (*table)->numberOfElements++; + return; + } + error = NOT_ERROR; +} + +void printValue(HashTable* table) +{ + int maximumListLength = numberOfElements(table->array[0]); + int numberOfCompletedBuckets = 0; + int totalSizeOfAllLists = 0; + for (int i = 0; i < table->numberOfSegment; i++) + { + print(table->array[i]); + if (!isEmpty(table->array[i])) + { + numberOfCompletedBuckets++; + } + int listLength = numberOfElements(table->array[i]); + totalSizeOfAllLists += listLength; + if (listLength > maximumListLength) + { + maximumListLength = listLength; + } + } + printf("maximum list lenght = %d\n", maximumListLength); + printf("hash table fill factor = %f\n", (float)(table->numberOfElements) / (float)(table->numberOfSegment)); + printf("average list length = %f\n", (float)(totalSizeOfAllLists) / (float)(numberOfCompletedBuckets)); +} + +bool inTable(HashTable* table, char* string) +{ + return inList(table->array[hashFunction(string, table)], string); +} + +int countNumberOfDuplicateItemsForSpecificList(char* value, HashTable* table) +{ + return returnNumberOfDuplicateValues(table->array[hashFunction(value, table)], value); +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/HashTable/HashTable/HashTable.h" "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.h" new file mode 100644 index 0000000..e18aaad --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.h" @@ -0,0 +1,23 @@ +#pragma once +#include "../../SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.h" + +// Structure representing a hash table +typedef struct HashTable HashTable; + +// Function for creating a hash table +HashTable* createTable(Error* error, int numberOfBuckets); + +// Function for deleting a hash table +void deleteHashTable(HashTable* table); + +// Function for adding an element to a hash table +void addElement(const char* string, HashTable** table, Error* error); + +// Function for printing values +void printValue(HashTable* table); + +// Function for checking the location of an element in the table +bool inTable(HashTable* table, char* string); + +// Function for counting the number of duplicate items for a specific list +int countNumberOfDuplicateItemsForSpecificList(char* value, HashTable* table); \ No newline at end of file diff --git "a/Homework \342\204\226 9/HashTable/HashTable/HashTable.vcxproj" "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.vcxproj" new file mode 100644 index 0000000..a5aea2f --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.vcxproj" @@ -0,0 +1,155 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {7f515015-3f19-4a2a-9f71-2b4e17988297} + HashTable + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Homework \342\204\226 9/HashTable/HashTable/HashTable.vcxproj.filters" "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.vcxproj.filters" new file mode 100644 index 0000000..6732d01 --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable/HashTable.vcxproj.filters" @@ -0,0 +1,42 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + + + Файлы заголовков + + + Файлы заголовков + + + Файлы заголовков + + + \ No newline at end of file diff --git "a/Homework \342\204\226 9/HashTable/HashTable/Main.c" "b/Homework \342\204\226 9/HashTable/HashTable/Main.c" new file mode 100644 index 0000000..fec8f6a --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable/Main.c" @@ -0,0 +1,11 @@ +#include "TestHashTable.h" +#include "HashTable.h" +#include + +int main() +{ + if (!testAddElement()) + { + return -1; + } +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/HashTable/HashTable/TestHashTable.c" "b/Homework \342\204\226 9/HashTable/HashTable/TestHashTable.c" new file mode 100644 index 0000000..cfe5b1f --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable/TestHashTable.c" @@ -0,0 +1,16 @@ +#include "TestHashTable.h" +#include "HashTable.h" + +bool testAddElement() +{ + Error error = NOT_ERROR; + HashTable* table = createTable(&error, 10); + addElement("Hello", &table, &error); + addElement("World", &table, &error); + addElement("Test", &table, &error); + bool firstResult = inTable(table, "Hello"); + bool secondResult = inTable(table, "World"); + bool thirdResult = inTable(table, "Test"); + deleteHashTable(table); + return firstResult && secondResult && thirdResult; +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/HashTable/HashTable/TestHashTable.h" "b/Homework \342\204\226 9/HashTable/HashTable/TestHashTable.h" new file mode 100644 index 0000000..3951eb9 --- /dev/null +++ "b/Homework \342\204\226 9/HashTable/HashTable/TestHashTable.h" @@ -0,0 +1,5 @@ +#pragma once +#include + +// Function to check the function to add an element +bool testAddElement(); diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.sln" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.sln" new file mode 100644 index 0000000..d81aa68 --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.sln" @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31410.357 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SinglyLinkedListForHashTable", "SinglyLinkedListForHashTable\SinglyLinkedListForHashTable.vcxproj", "{ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Debug|x64.ActiveCfg = Debug|x64 + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Debug|x64.Build.0 = Debug|x64 + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Debug|x86.ActiveCfg = Debug|Win32 + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Debug|x86.Build.0 = Debug|Win32 + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Release|x64.ActiveCfg = Release|x64 + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Release|x64.Build.0 = Release|x64 + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Release|x86.ActiveCfg = Release|Win32 + {ABF8D20F-CBDB-4353-9BCC-D9ECC7866F3E}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {91BE3025-E290-44D1-8BF0-D958E20D7DD7} + EndGlobalSection +EndGlobal diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/Main.c" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/Main.c" new file mode 100644 index 0000000..3be54fc --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/Main.c" @@ -0,0 +1,9 @@ +#include "TestSinglyLinkedListForHashTable.h" + +int main() +{ + if (!allTest()) + { + return -1; + } +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.c" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.c" new file mode 100644 index 0000000..54dc4dd --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.c" @@ -0,0 +1,251 @@ +#include "SinglyLinkedListForHashTable.h" +#include +#include +#include +#include + +// Structure containing pointers to the beginning and end of the list +typedef struct List +{ + int size; + struct ListElement* head; +} List; + +// Structure containing a pointer to the next list item and a value variable for the list items +typedef struct ListElement +{ + int numberOfDuplicateValues; + char* value; + struct ListElement* next; +} ListElement; + +// Structure containing a pointer to a ListElement +typedef struct Position +{ + ListElement* position; +} Position; + +List* createList(Error* error) +{ + List* list = calloc(1, sizeof(List)); + if (list == NULL) + { + *error = INSUFFICIENT_MEMORY; + } + return list; +} + +void deleteList(List* list) +{ + ListElement* position = list->head; + while (position != NULL) + { + list->head = list->head->next; + free(position->value); + free(position); + position = list->head; + } + free(list); +} + +void deletePosition(Position* position) +{ + free(position); +} + +bool isOneElement(List* list) +{ + return list->head->next == NULL; +} + +void removeFirstElement(List* list, Error* error) +{ + if (*error != NOT_ERROR) + { + return; + } + if (list->head == NULL) + { + *error = EMPTY_LIST; + return; + } + if (isOneElement(list) && list->head->numberOfDuplicateValues == 1) + { + list->size = 0; + free(list->head->value); + free(list->head); + list->head = NULL; + return; + } + ListElement* element = list->head; + if (element->numberOfDuplicateValues > 1) + { + element->numberOfDuplicateValues--; + return; + } + list->head = list->head->next; + list->size--; + free(element->value); + free(element); + +} + +Position* first(List* list, Error* error) +{ + if (*error != NOT_ERROR) + { + return NULL; + } + Position* positionFirst = malloc(sizeof(Position)); + if (positionFirst == NULL) + { + *error = EMPTY_LIST; + return NULL; + } + positionFirst->position = list->head; + return positionFirst; +} + +Position* next(Position* position) +{ + position->position = position->position->next; + return position; +} + +int numberOfElements(List* list) +{ + return list->size; +} + +char* getHeadValue(List* list) +{ + if (list->head == NULL) + { + return NULL; + } + return list->head->value; +} + +void add(List* list, const char* value, Error* error) +{ + if (*error != NOT_ERROR) + { + return; + } + if (list->head == NULL) + { + char* valueCopy = calloc(strlen(value) + 1, sizeof(char)); + if (valueCopy == NULL) + { + *error = INSUFFICIENT_MEMORY; + return; + } + strcpy(valueCopy, value); + ListElement* newElement = calloc(1, sizeof(ListElement)); + if (newElement == NULL) + { + free(valueCopy); + *error = INSUFFICIENT_MEMORY; + return; + } + newElement->value = valueCopy; + list->size = 1; + list->head = newElement; + list->head->numberOfDuplicateValues = 1; + return; + } + ListElement* element = list->head; + while (element != NULL) + { + if (strcmp(value, element->value) == 0) + { + element->numberOfDuplicateValues++; + *error = ELEMENT_REPEATS; + return; + } + element = element->next; + } + if (element == NULL) + { + char* valueCopy = calloc(strlen(value) + 1, sizeof(char)); + if (valueCopy == NULL) + { + *error = INSUFFICIENT_MEMORY; + return; + } + strcpy(valueCopy, value); + ListElement* newElement = calloc(1, sizeof(ListElement)); + if (newElement == NULL) + { + free(valueCopy); + *error = INSUFFICIENT_MEMORY; + return; + } + newElement->value = valueCopy; + newElement->next = list->head; + list->head = newElement; + list->size++; + newElement->numberOfDuplicateValues = 1; + } +} + +char* getValue(Position* position) +{ + return position->position->value; +} + +bool isEmpty(List* list) +{ + return list->head == NULL; +} + +void print(List* list) +{ + ListElement* element = list->head; + while (element != NULL) + { + printf("%s - %d\n", element->value, element->numberOfDuplicateValues); + element = element->next; + } +} + +const char* decodingError(Error error) +{ + if (error == EMPTY_LIST) + { + return "Error in the program"; + } + if (error == INSUFFICIENT_MEMORY) + { + return "Memory not allocated"; + } + return NULL; +} + +bool inList(List* list, const char* value) +{ + ListElement* element = list->head; + while (element != NULL) + { + if (strcmp(value, element->value) == 0) + { + return true; + } + element = element->next; + } + return false; +} + +int returnNumberOfDuplicateValues(List* list, const char* value) +{ + ListElement* element = list->head; + while (element != NULL) + { + if (strcmp(value, element->value) == 0) + { + return element->numberOfDuplicateValues; + } + element = element->next; + } + return 0; +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.h" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.h" new file mode 100644 index 0000000..118b596 --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.h" @@ -0,0 +1,62 @@ +#pragma once +#include + +// Structure that represents list +typedef struct List List; + +// This is a structure describing the position of an item in the list. +typedef struct Position Position; + +// Enum type for working with errors +typedef enum Error +{ + NOT_ERROR, + EMPTY_LIST, + INSUFFICIENT_MEMORY, + ELEMENT_REPEATS +} Error; + +// Function for creating a list +List* createList(Error* error); + +// Function for deleting a list +void deleteList(List* list); + +// Function for freeing up memory +void deletePosition(Position* position); + +// Function for adding an item to a list +void add(List* list, const char* value, Error* error); + +// function to find a position to the first element +Position* first(List* list, Error* error); + +// Function for finding a position to the next element +Position* next(Position* position); + +// Function for printing a list +void print(List* list); + +// Function for deleting the first element +void removeFirstElement(List* list, Error* error); + +// Function for finding the number of items in the list +int numberOfElements(List* list); + +// Function for checking the emptiness of the list +bool isEmpty(List* list); + +// Function that returns a value for the first element +char* getHeadValue(List* list); + +// Function that returns a value of element +char* getValue(Position* position); + +// Function for error decoding +const char* decodingError(Error error); + +// Function for determining the location of an item in the list +bool inList(List* list, const char* value); + +// Function for counting the number of duplicate elements +int returnNumberOfDuplicateValues(List* list, const char* value); \ No newline at end of file diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.vcxproj" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.vcxproj" new file mode 100644 index 0000000..0fe234a --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.vcxproj" @@ -0,0 +1,153 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {abf8d20f-cbdb-4353-9bcc-d9ecc7866f3e} + SinglyLinkedListForHashTable + 10.0 + + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + Application + true + v142 + Unicode + + + Application + false + v142 + true + Unicode + + + + + + + + + + + + + + + + + + + + + true + + + false + + + true + + + false + + + + Level3 + true + WIN32;_DEBUG;_CRT_SECURE_NO_WARNINGS;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + + + + + + + \ No newline at end of file diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.vcxproj.filters" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.vcxproj.filters" new file mode 100644 index 0000000..950f937 --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable.vcxproj.filters" @@ -0,0 +1,36 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Исходные файлы + + + Исходные файлы + + + Исходные файлы + + + + + Файлы заголовков + + + Файлы заголовков + + + \ No newline at end of file diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/TestSinglyLinkedListForHashTable.c" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/TestSinglyLinkedListForHashTable.c" new file mode 100644 index 0000000..d6d550c --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/TestSinglyLinkedListForHashTable.c" @@ -0,0 +1,86 @@ +#include "TestSinglyLinkedListForHashTable.h" +#include "SinglyLinkedListForHashTable.h" +#include + +// Function to check the function that adds an item to the list +bool testAdd() +{ + Error error = NOT_ERROR; + List* newList = createList(&error); + add(newList, "test", &error); + const char* firstValue = getHeadValue(newList); + add(newList, "list", &error); + const char* secondValue = getHeadValue(newList); + bool result = strcmp(firstValue, "test") == 0 && strcmp(secondValue, "list") == 0; + deleteList(newList); + return result; +} + +// Function to check the function that deletes the first item in the list +bool testRemoveHead() +{ + Error error = NOT_ERROR; + List* newList = createList(&error); + add(newList, "Hello", &error); + add(newList, "World", &error); + removeFirstElement(newList, &error); + if (error == EMPTY_LIST || error == INSUFFICIENT_MEMORY) + { + deleteList(newList); + return false; + } + const char* value = getHeadValue(newList); + bool result = strcmp(value, "Hello") == 0; + deleteList(newList); + return result; +} + +// Function for checking the function counting the number of elements +bool testNumberOfElements() +{ + Error error = NOT_ERROR; + List* newList = createList(&error); + add(newList, "Hello", &error); + add(newList, "Merge", &error); + add(newList, "test", &error); + add(newList, "list", &error); + if (error == INSUFFICIENT_MEMORY) + { + deleteList(newList); + return false; + } + const int number = numberOfElements(newList); + deleteList(newList); + return number == 4; +} + +// Function that checks the function that returns the value of the first element +bool testGetValue() +{ + Error error = NOT_ERROR; + List* newList = createList(&error); + add(newList, "Hello", &error); + add(newList, "World", &error); + if (error == INSUFFICIENT_MEMORY) + { + deleteList(newList); + return false; + } + Position* position = first(newList, &error); + if (error == EMPTY_LIST) + { + deleteList(newList); + return false; + } + const char* firstValue = getHeadValue(newList); + const char* secondValue = getValue(next(position)); + bool result = strcmp(firstValue, "World") == 0 && strcmp(secondValue, "Hello") == 0; + deleteList(newList); + deletePosition(position); + return result; +} + +bool allTest() +{ + return testAdd() && testRemoveHead() && testNumberOfElements() && testGetValue(); +} \ No newline at end of file diff --git "a/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/TestSinglyLinkedListForHashTable.h" "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/TestSinglyLinkedListForHashTable.h" new file mode 100644 index 0000000..737bfba --- /dev/null +++ "b/Homework \342\204\226 9/SinglyLinkedListForHashTable/SinglyLinkedListForHashTable/TestSinglyLinkedListForHashTable.h" @@ -0,0 +1,5 @@ +#pragma once +#include + +// A function that combines the results of all tests +bool allTest(); \ No newline at end of file