Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 Oct 15, 2021
2549f2f
fixed bugs
MinyazevR Oct 15, 2021
14417f4
Merge branch 'main' of https://github.com/MinyazevR/Homework-1-sem in…
MinyazevR Oct 15, 2021
8d6727e
fixed bugs
MinyazevR Oct 15, 2021
e7e22d6
add function
MinyazevR Oct 16, 2021
2f9e2a0
fixed bugs
MinyazevR Oct 16, 2021
a04a9a8
writing all functions, text and comments
MinyazevR Oct 16, 2021
ac6b390
fixed bugs
MinyazevR Oct 16, 2021
015e87e
fixed bugs
MinyazevR Oct 16, 2021
5d2e300
Merge pull request #16 from MinyazevR/Stack
MinyazevR Oct 16, 2021
d85663e
fixed bugs
MinyazevR Oct 22, 2021
6a502c1
fixed bugs
MinyazevR Oct 22, 2021
cf515a4
Merge pull request #21 from MinyazevR/Stack
MinyazevR Oct 22, 2021
77c9d15
fixed bugs
MinyazevR Oct 22, 2021
0dfb7c2
fixed bugs
MinyazevR Oct 22, 2021
400b92a
start
MinyazevR Oct 22, 2021
b720cdc
adding a function that returns the value of an element from the top o…
MinyazevR Oct 22, 2021
22af234
Merge pull request #22 from MinyazevR/Stack
MinyazevR Oct 22, 2021
3bfe82a
the beginning of writing the program
MinyazevR Oct 22, 2021
519399b
Merge pull request #24 from MinyazevR/Stack
MinyazevR Oct 22, 2021
41ce912
part of the function is written
MinyazevR Oct 22, 2021
c713a82
fixed bugs
MinyazevR Oct 22, 2021
b49b752
writing a function
MinyazevR Oct 22, 2021
9a45a27
fixed bugs
MinyazevR Oct 22, 2021
b501bc2
Merge pull request #25 from MinyazevR/Stack
MinyazevR Oct 22, 2021
ae4b6a9
fixed bugs
MinyazevR Oct 22, 2021
b04b391
correction of some errors
MinyazevR Oct 23, 2021
e226c08
fixed test
MinyazevR Oct 23, 2021
13aa804
correction of an error related to the absence of main.c
MinyazevR Oct 23, 2021
954da9f
correction of defects related to the styleguide
MinyazevR Oct 23, 2021
a121942
fixed bugs
MinyazevR Oct 23, 2021
fe152de
adding a test for a function
MinyazevR Oct 23, 2021
1e1980f
Merge branch 'BalanceBrackets' into Stack
MinyazevR Oct 23, 2021
f1afee9
Merge pull request #27 from MinyazevR/Stack
MinyazevR Oct 23, 2021
c97644a
Merge branch 'SortingStation' of https://github.com/MinyazevR/Homewor…
MinyazevR Oct 23, 2021
6535156
adding test, function and comments
MinyazevR Oct 23, 2021
f8c6b6c
fixed bugs
MinyazevR Oct 24, 2021
1bb324a
bug fix (now the program works to translate any numbers, not just dig…
MinyazevR Oct 24, 2021
c3488e0
fixed bugs
MinyazevR Oct 24, 2021
ddba2ac
Merge pull request #28 from MinyazevR/Stack
MinyazevR Oct 24, 2021
a6443f5
fixed bugs related to error values
MinyazevR Oct 25, 2021
d1fd65f
changing tests, function arguments
MinyazevR Oct 25, 2021
46e663e
changing tests, function arguments
MinyazevR Oct 25, 2021
128ce17
removed the space bar
MinyazevR Oct 25, 2021
9c875d3
fixed a problem with spaces
MinyazevR Oct 26, 2021
c118f06
add several function, changed test
MinyazevR Oct 26, 2021
b098b7e
fixed top()
MinyazevR Oct 26, 2021
b58ccb8
fixed push()
MinyazevR Nov 4, 2021
99706f1
Merge branch 'SortingStation' into Stack
MinyazevR Nov 4, 2021
bd05460
Merge pull request #33 from MinyazevR/Stack
MinyazevR Nov 4, 2021
a5b71c9
added new features, fixed memory leaks
MinyazevR Nov 4, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Stack/Stack.sln
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
11 changes: 11 additions & 0 deletions Stack/Stack/Main.c
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;
}
}
61 changes: 61 additions & 0 deletions Stack/Stack/Stack.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#include "Stack.h"
#include <malloc.h>

bool isEmpty(Stack* head)
{
return head == NULL;
}

Stack* createStack()
{
return NULL;
}

void push(Stack** head, int element, int* error)
{
*error = 0;
Stack* newStack = (Stack*)calloc(1, sizeof(Stack));
if (newStack == NULL)
{
*error = 2;
return;
}
newStack->value = element;
newStack->next = *head;
*head = newStack;
}

int pop(Stack** head, int* error)
{
*error = 0;
if (*head == NULL)
{
*error = 1;
return 0;
}
const int element = (*head)->value;
Stack* temporary = *head;
*head = (*head)->next;
free(temporary);
return element;
}

void deleteStack(Stack** head)
{
int error = 0;
while (!isEmpty(*head))
{
pop(head, &error);
}
}

int top(Stack** head, int* error)
{
*error = 0;
if (isEmpty(*head))
{
*error = 1;
return 0;
}
return (*head)->value;
}
27 changes: 27 additions & 0 deletions Stack/Stack/Stack.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#pragma once
#include <stdbool.h>

// Structure for implementing a stack consisting of a value and a pointer to the next element
typedef struct Stack
{
int 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, int element, int* error);

// Function to remove an element from the top of the stack that returns the value of that element
int pop(Stack** head, int* error);

// Function for deleting all stack elements
void deleteStack(Stack** head);

// Creating a stack
Stack* createStack();

// Function that returns the value of an element from the top of the stack
int top(Stack** head, int* error);
153 changes: 153 additions & 0 deletions Stack/Stack/Stack.vcxproj
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>
36 changes: 36 additions & 0 deletions Stack/Stack/Stack.vcxproj.filters
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>
Loading