-
Notifications
You must be signed in to change notification settings - Fork 0
Sorting station #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
MinyazevR
wants to merge
51
commits into
main
Choose a base branch
from
SortingStation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Sorting station #23
Changes from 44 commits
Commits
Show all changes
51 commits
Select commit
Hold shift + click to select a range
1a83386
creating functions for working with the stack and testing them
MinyazevR 2549f2f
fixed bugs
MinyazevR 14417f4
Merge branch 'main' of https://github.com/MinyazevR/Homework-1-sem in…
MinyazevR 8d6727e
fixed bugs
MinyazevR e7e22d6
add function
MinyazevR 2f9e2a0
fixed bugs
MinyazevR a04a9a8
writing all functions, text and comments
MinyazevR ac6b390
fixed bugs
MinyazevR 015e87e
fixed bugs
MinyazevR 5d2e300
Merge pull request #16 from MinyazevR/Stack
MinyazevR d85663e
fixed bugs
MinyazevR 6a502c1
fixed bugs
MinyazevR cf515a4
Merge pull request #21 from MinyazevR/Stack
MinyazevR 77c9d15
fixed bugs
MinyazevR 0dfb7c2
fixed bugs
MinyazevR 400b92a
start
MinyazevR b720cdc
adding a function that returns the value of an element from the top o…
MinyazevR 22af234
Merge pull request #22 from MinyazevR/Stack
MinyazevR 3bfe82a
the beginning of writing the program
MinyazevR 519399b
Merge pull request #24 from MinyazevR/Stack
MinyazevR 41ce912
part of the function is written
MinyazevR c713a82
fixed bugs
MinyazevR b49b752
writing a function
MinyazevR 9a45a27
fixed bugs
MinyazevR b501bc2
Merge pull request #25 from MinyazevR/Stack
MinyazevR ae4b6a9
fixed bugs
MinyazevR b04b391
correction of some errors
MinyazevR e226c08
fixed test
MinyazevR 13aa804
correction of an error related to the absence of main.c
MinyazevR 954da9f
correction of defects related to the styleguide
MinyazevR a121942
fixed bugs
MinyazevR fe152de
adding a test for a function
MinyazevR 1e1980f
Merge branch 'BalanceBrackets' into Stack
MinyazevR f1afee9
Merge pull request #27 from MinyazevR/Stack
MinyazevR c97644a
Merge branch 'SortingStation' of https://github.com/MinyazevR/Homewor…
MinyazevR 6535156
adding test, function and comments
MinyazevR f8c6b6c
fixed bugs
MinyazevR 1bb324a
bug fix (now the program works to translate any numbers, not just dig…
MinyazevR c3488e0
fixed bugs
MinyazevR ddba2ac
Merge pull request #28 from MinyazevR/Stack
MinyazevR a6443f5
fixed bugs related to error values
MinyazevR d1fd65f
changing tests, function arguments
MinyazevR 46e663e
changing tests, function arguments
MinyazevR 128ce17
removed the space bar
MinyazevR 9c875d3
fixed a problem with spaces
MinyazevR c118f06
add several function, changed test
MinyazevR b098b7e
fixed top()
MinyazevR b58ccb8
fixed push()
MinyazevR 99706f1
Merge branch 'SortingStation' into Stack
MinyazevR bd05460
Merge pull request #33 from MinyazevR/Stack
MinyazevR a5b71c9
added new features, fixed memory leaks
MinyazevR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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}") = "Stack", "Stack\Stack.vcxproj", "{A4F19B27-54C9-4841-98B0-728EDCD283D2}" | ||
| 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 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Debug|x64.ActiveCfg = Debug|x64 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Debug|x64.Build.0 = Debug|x64 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Debug|x86.ActiveCfg = Debug|Win32 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Debug|x86.Build.0 = Debug|Win32 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Release|x64.ActiveCfg = Release|x64 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Release|x64.Build.0 = Release|x64 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Release|x86.ActiveCfg = Release|Win32 | ||
| {A4F19B27-54C9-4841-98B0-728EDCD283D2}.Release|x86.Build.0 = Release|Win32 | ||
| EndGlobalSection | ||
| GlobalSection(SolutionProperties) = preSolution | ||
| HideSolutionNode = FALSE | ||
| EndGlobalSection | ||
| GlobalSection(ExtensibilityGlobals) = postSolution | ||
| SolutionGuid = {5B7E38AF-1E89-49D4-95EB-B55DB0F7ADDF} | ||
| EndGlobalSection | ||
| EndGlobal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #include "StackTest.h" | ||
| #include <stdio.h> | ||
|
|
||
| int main() | ||
| { | ||
| if (!pushTest() || !popTest() || !deleteStackTest() || !topTest()) | ||
| { | ||
| printf("Test failed"); | ||
| return -1; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,54 @@ | ||||||
| #include "Stack.h" | ||||||
| #include <malloc.h> | ||||||
|
|
||||||
| bool isEmpty(Stack* head) | ||||||
| { | ||||||
| return head == NULL; | ||||||
| } | ||||||
|
|
||||||
| void push(Stack** head, char element) | ||||||
| { | ||||||
| Stack* newStack = (Stack*)calloc(1, sizeof(Stack)); | ||||||
| if (newStack == NULL) | ||||||
| { | ||||||
| return; | ||||||
| } | ||||||
| newStack->value = element; | ||||||
| newStack->next = *head; | ||||||
| *head = newStack; | ||||||
| } | ||||||
|
|
||||||
| char pop(Stack** head, int* error) | ||||||
| { | ||||||
| *error = 0; | ||||||
| if (*head != NULL) | ||||||
| { | ||||||
| const char element = (*head)->value; | ||||||
| Stack* temporary = *head; | ||||||
| *head = (*head)->next; | ||||||
| free(temporary); | ||||||
| return element; | ||||||
| } | ||||||
| *error = 1; | ||||||
| return 0; | ||||||
| } | ||||||
|
|
||||||
| void deleteStack(Stack** head) | ||||||
| { | ||||||
| int error = 0; | ||||||
| while (!isEmpty(*head)) | ||||||
| { | ||||||
| pop(head, &error); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| char top(Stack** head, int* error) | ||||||
| { | ||||||
| *error = 0; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if (!isEmpty(*head)) | ||||||
| { | ||||||
| return (*head)->value; | ||||||
| } | ||||||
| *error = 1; | ||||||
| return 0; | ||||||
| } | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #pragma once | ||
| #include <stdbool.h> | ||
|
|
||
| // Structure for implementing a stack consisting of a value and a pointer to the next element | ||
| typedef struct Stack | ||
| { | ||
| char value; | ||
| struct Stack* next; | ||
| } Stack; | ||
|
|
||
| // Function for testing if stack is empty | ||
| bool isEmpty(Stack* head); | ||
|
|
||
| // Function for adding an element to the top of the stack | ||
| void push(Stack** head, char element); | ||
|
|
||
| // Function to remove an element from the top of the stack that returns the value of that element | ||
| char pop(Stack** head, int* error); | ||
|
|
||
| // Function for deleting all stack elements | ||
| void deleteStack(Stack** head); | ||
|
|
||
| // Function that returns the value of an element from the top of the stack | ||
| char top(Stack** head, int* error); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <ItemGroup Label="ProjectConfigurations"> | ||
| <ProjectConfiguration Include="Debug|Win32"> | ||
| <Configuration>Debug</Configuration> | ||
| <Platform>Win32</Platform> | ||
| </ProjectConfiguration> | ||
| <ProjectConfiguration Include="Release|Win32"> | ||
| <Configuration>Release</Configuration> | ||
| <Platform>Win32</Platform> | ||
| </ProjectConfiguration> | ||
| <ProjectConfiguration Include="Debug|x64"> | ||
| <Configuration>Debug</Configuration> | ||
| <Platform>x64</Platform> | ||
| </ProjectConfiguration> | ||
| <ProjectConfiguration Include="Release|x64"> | ||
| <Configuration>Release</Configuration> | ||
| <Platform>x64</Platform> | ||
| </ProjectConfiguration> | ||
| </ItemGroup> | ||
| <PropertyGroup Label="Globals"> | ||
| <VCProjectVersion>16.0</VCProjectVersion> | ||
| <Keyword>Win32Proj</Keyword> | ||
| <ProjectGuid>{a4f19b27-54c9-4841-98b0-728edcd283d2}</ProjectGuid> | ||
| <RootNamespace>Stack</RootNamespace> | ||
| <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> | ||
| </PropertyGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> | ||
| <ConfigurationType>Application</ConfigurationType> | ||
| <UseDebugLibraries>true</UseDebugLibraries> | ||
| <PlatformToolset>v142</PlatformToolset> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> | ||
| <ConfigurationType>Application</ConfigurationType> | ||
| <UseDebugLibraries>false</UseDebugLibraries> | ||
| <PlatformToolset>v142</PlatformToolset> | ||
| <WholeProgramOptimization>true</WholeProgramOptimization> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> | ||
| <ConfigurationType>Application</ConfigurationType> | ||
| <UseDebugLibraries>true</UseDebugLibraries> | ||
| <PlatformToolset>v142</PlatformToolset> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> | ||
| <ConfigurationType>Application</ConfigurationType> | ||
| <UseDebugLibraries>false</UseDebugLibraries> | ||
| <PlatformToolset>v142</PlatformToolset> | ||
| <WholeProgramOptimization>true</WholeProgramOptimization> | ||
| <CharacterSet>Unicode</CharacterSet> | ||
| </PropertyGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> | ||
| <ImportGroup Label="ExtensionSettings"> | ||
| </ImportGroup> | ||
| <ImportGroup Label="Shared"> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | ||
| </ImportGroup> | ||
| <PropertyGroup Label="UserMacros" /> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| <LinkIncremental>true</LinkIncremental> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| <LinkIncremental>false</LinkIncremental> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <LinkIncremental>true</LinkIncremental> | ||
| </PropertyGroup> | ||
| <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <LinkIncremental>false</LinkIncremental> | ||
| </PropertyGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| </ClCompile> | ||
| <Link> | ||
| <SubSystem>Console</SubSystem> | ||
| <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| </Link> | ||
| </ItemDefinitionGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <FunctionLevelLinking>true</FunctionLevelLinking> | ||
| <IntrinsicFunctions>true</IntrinsicFunctions> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| </ClCompile> | ||
| <Link> | ||
| <SubSystem>Console</SubSystem> | ||
| <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
| <OptimizeReferences>true</OptimizeReferences> | ||
| <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| </Link> | ||
| </ItemDefinitionGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| </ClCompile> | ||
| <Link> | ||
| <SubSystem>Console</SubSystem> | ||
| <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| </Link> | ||
| </ItemDefinitionGroup> | ||
| <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> | ||
| <ClCompile> | ||
| <WarningLevel>Level3</WarningLevel> | ||
| <FunctionLevelLinking>true</FunctionLevelLinking> | ||
| <IntrinsicFunctions>true</IntrinsicFunctions> | ||
| <SDLCheck>true</SDLCheck> | ||
| <PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> | ||
| <ConformanceMode>true</ConformanceMode> | ||
| </ClCompile> | ||
| <Link> | ||
| <SubSystem>Console</SubSystem> | ||
| <EnableCOMDATFolding>true</EnableCOMDATFolding> | ||
| <OptimizeReferences>true</OptimizeReferences> | ||
| <GenerateDebugInformation>true</GenerateDebugInformation> | ||
| </Link> | ||
| </ItemDefinitionGroup> | ||
| <ItemGroup> | ||
| <ClCompile Include="Main.c" /> | ||
| <ClCompile Include="Stack.c" /> | ||
| <ClCompile Include="StackTest.c" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ClInclude Include="Stack.h" /> | ||
| <ClInclude Include="StackTest.h" /> | ||
| </ItemGroup> | ||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | ||
| <ImportGroup Label="ExtensionTargets"> | ||
| </ImportGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <ItemGroup> | ||
| <Filter Include="Исходные файлы"> | ||
| <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> | ||
| <Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions> | ||
| </Filter> | ||
| <Filter Include="Файлы заголовков"> | ||
| <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> | ||
| <Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions> | ||
| </Filter> | ||
| <Filter Include="Файлы ресурсов"> | ||
| <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> | ||
| <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> | ||
| </Filter> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ClCompile Include="StackTest.c"> | ||
| <Filter>Исходные файлы</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Main.c"> | ||
| <Filter>Исходные файлы</Filter> | ||
| </ClCompile> | ||
| <ClCompile Include="Stack.c"> | ||
| <Filter>Исходные файлы</Filter> | ||
| </ClCompile> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <ClInclude Include="Stack.h"> | ||
| <Filter>Файлы заголовков</Filter> | ||
| </ClInclude> | ||
| <ClInclude Include="StackTest.h"> | ||
| <Filter>Файлы заголовков</Filter> | ||
| </ClInclude> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| #include "StackTest.h" | ||
| #include "Stack.h" | ||
| #include <stdio.h> | ||
|
|
||
| bool pushTest() | ||
| { | ||
| Stack* head = NULL; | ||
| push(&head, '['); | ||
| const char firstResult = head->value; | ||
| push(&head, ')'); | ||
| const char secondResult = head->value; | ||
| deleteStack(&head); | ||
| return firstResult == '[' && secondResult == ')'; | ||
| } | ||
|
|
||
| bool popTest() | ||
| { | ||
| Stack* head = NULL; | ||
| push(&head, 'a'); | ||
| push(&head, '^'); | ||
| push(&head, '1'); | ||
| int error = 0; | ||
| const char firstPopResult = pop(&head, &error); | ||
| if (error == 1) | ||
| { | ||
| return false; | ||
| } | ||
| const char firstUpperElement = head->value; | ||
| const char secondPopResult = pop(&head, &error); | ||
| if (error == 1) | ||
| { | ||
| return false; | ||
| } | ||
| const char secondUpperElement = head->value; | ||
| deleteStack(&head); | ||
| return firstPopResult == '1' && firstUpperElement == '^' && secondPopResult == '^' && secondUpperElement == 'a'; | ||
| } | ||
|
|
||
| bool deleteStackTest() | ||
| { | ||
| Stack* head = NULL; | ||
| push(&head, 'a'); | ||
| push(&head, 'b'); | ||
| push(&head, 'c'); | ||
| deleteStack(&head); | ||
| return head == NULL; | ||
| } | ||
|
|
||
| bool topTest() | ||
| { | ||
| Stack* head = NULL; | ||
| push(&head, 'a'); | ||
| int error = 0; | ||
| const char firstTopResult = top(&head, &error); | ||
| if (error == 1) | ||
| { | ||
| return false; | ||
| } | ||
| push(&head, '^'); | ||
| const char secondTopResult = top(&head, &error); | ||
| if (error == 1) | ||
| { | ||
| return false; | ||
| } | ||
| push(&head, '1'); | ||
| const char thirdTopResult = top(&head, &error); | ||
| if (error == 1) | ||
| { | ||
| return false; | ||
| } | ||
| deleteStack(&head); | ||
| return firstTopResult == 'a' && secondTopResult == '^' && thirdTopResult == '1'; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы тут обратил условие if на самом деле, чтобы весь содержательный код был не под if