-
Notifications
You must be signed in to change notification settings - Fork 0
Advanced bracket balance. Kalsina Yana. #7
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
yaprogrammer18-yanchi
wants to merge
23
commits into
main
Choose a base branch
from
bracket_balance_task_branch
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
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
ef7191b
Add stack.c and stack.h
yaprogrammer18-yanchi b6b1a3f
Slightly change stack.c and stack.h
yaprogrammer18-yanchi 8eec1d6
Add advancedBracketBalance task
yaprogrammer18-yanchi 24094b3
Remove empty line
yaprogrammer18-yanchi 00d5be0
Removed struct realisation from h to c and fix some mistakes that thi…
yaprogrammer18-yanchi aa47c61
update stack version in more advanced one
yaprogrammer18-yanchi 4dcee2c
Resolve the conflict in stack.c and stack.h files
yaprogrammer18-yanchi df951c6
Add cmake files, changed the file strusture. Now AdvBrBal task and st…
yaprogrammer18-yanchi 4f596e8
Changed one letter in CMakelists.txt
yaprogrammer18-yanchi 29c0959
Changed one more letter in CMakelists.txt
yaprogrammer18-yanchi 6917e2c
Changed and one more letter in CMakelists.txt
yaprogrammer18-yanchi c68f8ae
Revert "Changed one more letter in CMakelists.txt"
yaprogrammer18-yanchi 076cddd
Changed one letter in CMake file
yaprogrammer18-yanchi b9f38cf
Add flags in cMake file
yaprogrammer18-yanchi ca673b6
Add clang-format config
yaprogrammer18-yanchi 2ede7da
Fix mistakes in stack.h and stack.c
yaprogrammer18-yanchi 6a2b7e5
Fix other mistakes in stack.c add built in .gitignore
yaprogrammer18-yanchi 03128ee
Add clang-format config + resolved the conflict with stack files
yaprogrammer18-yanchi d0aa365
Fix advanced braket balance task
yaprogrammer18-yanchi b936d74
Changed stack.h and main file just removed some empty spaces
yaprogrammer18-yanchi ab8c2c1
fix stack.h
yaprogrammer18-yanchi 83d1991
tmp to ch comspile to compile added break on 31 line
yaprogrammer18-yanchi d67a2dc
ch now is new with every iteration
yaprogrammer18-yanchi 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,244 @@ | ||
| --- | ||
| Language: Cpp | ||
| # BasedOnStyle: WebKit | ||
| AccessModifierOffset: -4 | ||
| AlignAfterOpenBracket: DontAlign | ||
| AlignArrayOfStructures: None | ||
| AlignConsecutiveAssignments: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: true | ||
| AlignConsecutiveBitFields: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: false | ||
| AlignConsecutiveDeclarations: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: false | ||
| AlignConsecutiveMacros: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCompound: false | ||
| AlignFunctionPointers: false | ||
| PadOperators: false | ||
| AlignConsecutiveShortCaseStatements: | ||
| Enabled: false | ||
| AcrossEmptyLines: false | ||
| AcrossComments: false | ||
| AlignCaseColons: false | ||
| AlignEscapedNewlines: Right | ||
| AlignOperands: DontAlign | ||
| AlignTrailingComments: | ||
| Kind: Never | ||
| OverEmptyLines: 0 | ||
| AllowAllArgumentsOnNextLine: true | ||
| AllowAllParametersOfDeclarationOnNextLine: true | ||
| AllowBreakBeforeNoexceptSpecifier: Never | ||
| AllowShortBlocksOnASingleLine: Empty | ||
| AllowShortCaseLabelsOnASingleLine: false | ||
| AllowShortCompoundRequirementOnASingleLine: true | ||
| AllowShortEnumsOnASingleLine: true | ||
| AllowShortFunctionsOnASingleLine: All | ||
| AllowShortIfStatementsOnASingleLine: Never | ||
| AllowShortLambdasOnASingleLine: All | ||
| AllowShortLoopsOnASingleLine: false | ||
| AlwaysBreakAfterDefinitionReturnType: None | ||
| AlwaysBreakAfterReturnType: None | ||
| AlwaysBreakBeforeMultilineStrings: false | ||
| AlwaysBreakTemplateDeclarations: MultiLine | ||
| AttributeMacros: | ||
| - __capability | ||
| BinPackArguments: true | ||
| BinPackParameters: true | ||
| BitFieldColonSpacing: Both | ||
| BraceWrapping: | ||
| AfterCaseLabel: false | ||
| AfterClass: false | ||
| AfterControlStatement: Never | ||
| AfterEnum: false | ||
| AfterExternBlock: false | ||
| AfterFunction: true | ||
| AfterNamespace: false | ||
| AfterObjCDeclaration: false | ||
| AfterStruct: false | ||
| AfterUnion: false | ||
| BeforeCatch: false | ||
| BeforeElse: false | ||
| BeforeLambdaBody: false | ||
| BeforeWhile: false | ||
| IndentBraces: false | ||
| SplitEmptyFunction: true | ||
| SplitEmptyRecord: true | ||
| SplitEmptyNamespace: true | ||
| BreakAdjacentStringLiterals: true | ||
| BreakAfterAttributes: Leave | ||
| BreakAfterJavaFieldAnnotations: false | ||
| BreakArrays: true | ||
| BreakBeforeBinaryOperators: All | ||
| BreakBeforeConceptDeclarations: Always | ||
| BreakBeforeBraces: WebKit | ||
| BreakBeforeInlineASMColon: OnlyMultiline | ||
| BreakBeforeTernaryOperators: true | ||
| BreakConstructorInitializers: BeforeComma | ||
| BreakInheritanceList: BeforeColon | ||
| BreakStringLiterals: true | ||
| ColumnLimit: 0 | ||
| CommentPragmas: '^ IWYU pragma:' | ||
| CompactNamespaces: false | ||
| ConstructorInitializerIndentWidth: 4 | ||
| ContinuationIndentWidth: 4 | ||
| Cpp11BracedListStyle: false | ||
| DerivePointerAlignment: false | ||
| DisableFormat: false | ||
| EmptyLineAfterAccessModifier: Never | ||
| EmptyLineBeforeAccessModifier: LogicalBlock | ||
| ExperimentalAutoDetectBinPacking: false | ||
| FixNamespaceComments: false | ||
| ForEachMacros: | ||
| - foreach | ||
| - Q_FOREACH | ||
| - BOOST_FOREACH | ||
| IfMacros: | ||
| - KJ_IF_MAYBE | ||
| IncludeBlocks: Preserve | ||
| IncludeCategories: | ||
| - Regex: '^"(llvm|llvm-c|clang|clang-c)/' | ||
| Priority: 2 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| - Regex: '^(<|"(gtest|gmock|isl|json)/)' | ||
| Priority: 3 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| - Regex: '.*' | ||
| Priority: 1 | ||
| SortPriority: 0 | ||
| CaseSensitive: false | ||
| IncludeIsMainRegex: '(Test)?$' | ||
| IncludeIsMainSourceRegex: '' | ||
| IndentAccessModifiers: false | ||
| IndentCaseBlocks: false | ||
| IndentCaseLabels: false | ||
| IndentExternBlock: AfterExternBlock | ||
| IndentGotoLabels: true | ||
| IndentPPDirectives: None | ||
| IndentRequiresClause: true | ||
| IndentWidth: 4 | ||
| IndentWrappedFunctionNames: false | ||
| InsertBraces: false | ||
| InsertNewlineAtEOF: false | ||
| InsertTrailingCommas: None | ||
| IntegerLiteralSeparator: | ||
| Binary: 0 | ||
| BinaryMinDigits: 0 | ||
| Decimal: 0 | ||
| DecimalMinDigits: 0 | ||
| Hex: 0 | ||
| HexMinDigits: 0 | ||
| JavaScriptQuotes: Leave | ||
| JavaScriptWrapImports: true | ||
| KeepEmptyLinesAtTheStartOfBlocks: true | ||
| KeepEmptyLinesAtEOF: false | ||
| LambdaBodyIndentation: Signature | ||
| LineEnding: DeriveLF | ||
| MacroBlockBegin: '' | ||
| MacroBlockEnd: '' | ||
| MaxEmptyLinesToKeep: 1 | ||
| NamespaceIndentation: Inner | ||
| ObjCBinPackProtocolList: Auto | ||
| ObjCBlockIndentWidth: 4 | ||
| ObjCBreakBeforeNestedBlockParam: true | ||
| ObjCSpaceAfterProperty: true | ||
| ObjCSpaceBeforeProtocolList: true | ||
| PackConstructorInitializers: BinPack | ||
| PenaltyBreakAssignment: 2 | ||
| PenaltyBreakBeforeFirstCallParameter: 19 | ||
| PenaltyBreakComment: 300 | ||
| PenaltyBreakFirstLessLess: 120 | ||
| PenaltyBreakOpenParenthesis: 0 | ||
| PenaltyBreakScopeResolution: 500 | ||
| PenaltyBreakString: 1000 | ||
| PenaltyBreakTemplateDeclaration: 10 | ||
| PenaltyExcessCharacter: 1000000 | ||
| PenaltyIndentedWhitespace: 0 | ||
| PenaltyReturnTypeOnItsOwnLine: 60 | ||
| PointerAlignment: Left | ||
| PPIndentWidth: -1 | ||
| QualifierAlignment: Leave | ||
| ReferenceAlignment: Pointer | ||
| ReflowComments: true | ||
| RemoveBracesLLVM: false | ||
| RemoveParentheses: Leave | ||
| RemoveSemicolon: false | ||
| RequiresClausePosition: OwnLine | ||
| RequiresExpressionIndentation: OuterScope | ||
| SeparateDefinitionBlocks: Leave | ||
| ShortNamespaceLines: 1 | ||
| SkipMacroDefinitionBody: false | ||
| SortIncludes: CaseSensitive | ||
| SortJavaStaticImport: Before | ||
| SortUsingDeclarations: LexicographicNumeric | ||
| SpaceAfterCStyleCast: false | ||
| SpaceAfterLogicalNot: false | ||
| SpaceAfterTemplateKeyword: true | ||
| SpaceAroundPointerQualifiers: Default | ||
| SpaceBeforeAssignmentOperators: true | ||
| SpaceBeforeCaseColon: false | ||
| SpaceBeforeCpp11BracedList: true | ||
| SpaceBeforeCtorInitializerColon: true | ||
| SpaceBeforeInheritanceColon: true | ||
| SpaceBeforeJsonColon: false | ||
| SpaceBeforeParens: ControlStatements | ||
| SpaceBeforeParensOptions: | ||
| AfterControlStatements: true | ||
| AfterForeachMacros: true | ||
| AfterFunctionDefinitionName: false | ||
| AfterFunctionDeclarationName: false | ||
| AfterIfMacros: true | ||
| AfterOverloadedOperator: false | ||
| AfterPlacementOperator: true | ||
| AfterRequiresInClause: false | ||
| AfterRequiresInExpression: false | ||
| BeforeNonEmptyParentheses: false | ||
| SpaceBeforeRangeBasedForLoopColon: true | ||
| SpaceBeforeSquareBrackets: false | ||
| SpaceInEmptyBlock: true | ||
| SpacesBeforeTrailingComments: 1 | ||
| SpacesInAngles: Never | ||
| SpacesInContainerLiterals: true | ||
| SpacesInLineCommentPrefix: | ||
| Minimum: 1 | ||
| Maximum: -1 | ||
| SpacesInParens: Never | ||
| SpacesInParensOptions: | ||
| InCStyleCasts: false | ||
| InConditionalStatements: false | ||
| InEmptyParentheses: false | ||
| Other: false | ||
| SpacesInSquareBrackets: false | ||
| Standard: Latest | ||
| StatementAttributeLikeMacros: | ||
| - Q_EMIT | ||
| StatementMacros: | ||
| - Q_UNUSED | ||
| - QT_REQUIRE_VERSION | ||
| TabWidth: 8 | ||
| UseTab: Never | ||
| VerilogBreakBetweenInstancePorts: true | ||
| WhitespaceSensitiveMacros: | ||
| - BOOST_PP_STRINGIZE | ||
| - CF_SWIFT_NAME | ||
| - NS_SWIFT_NAME | ||
| - PP_STRINGIZE | ||
| - STRINGIZE |
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
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,7 @@ | ||
| cmake_minimum_required(VERSION 3.25) | ||
|
|
||
| project(C_Homework C) | ||
|
|
||
| add_subdirectory(src/AdvancedBracketBalance) | ||
|
|
||
| add_compile_options(-Wall -Wextra -Wpedantic) |
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,5 @@ | ||
| add_library(stack stack.c) | ||
|
|
||
| add_executable(advancedBracketBalance advancedBracketBalance.c) | ||
|
|
||
| target_link_libraries(advancedBracketBalance PRIVATE stack) |
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,53 @@ | ||
| #include "stack.h" | ||
| #include <stdbool.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
| #include <string.h> | ||
|
|
||
| bool checkBrackets(char* stringWithBrackets) | ||
| { | ||
| bool isBalanced = true; | ||
| Stack* stack = newStack(); | ||
| int length = strlen(stringWithBrackets); | ||
| for (int i = 0; i < length; i++) { | ||
| char ch = stringWithBrackets[i]; | ||
| if ((ch == '(') || (ch == '{') || (ch == '[')) { | ||
| push(stack, ch); | ||
| } | ||
| // если встретилась закрывающаяся и стек не пустой | ||
| else if ((ch == ')' || ch == '}' || ch == ']') && (!isEmpty(stack))) { | ||
| char previousBracket = pop(stack); | ||
| if ((previousBracket == '(' && ch == ')') || (previousBracket == '[' && ch == ']') || (previousBracket == '{' && ch == '}')) { | ||
| continue; | ||
| } else { | ||
| isBalanced = false; | ||
| break; | ||
| } | ||
| } | ||
| // закрывающаяся и пустой стек | ||
| else if ((ch == ')' || ch == '}' || ch == ']') && (isEmpty(stack))) { | ||
| isBalanced = false; | ||
| break; | ||
| } | ||
| } | ||
| if (!isEmpty(stack)) { | ||
| isBalanced = false; | ||
| } | ||
| deleteStack(stack); | ||
| return isBalanced; | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| char* stringWithBrackets = malloc(1000 * sizeof(char)); | ||
| printf("Введите скобочную последовательность: "); | ||
| scanf("%s", stringWithBrackets); | ||
| bool isCorrect = checkBrackets(stringWithBrackets); | ||
| if (isCorrect) { | ||
| printf("Скобочная последовательность правильная\n"); | ||
| } else { | ||
| printf("Скобочная последовательность неправильная\n"); | ||
| } | ||
| free(stringWithBrackets); | ||
| 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,56 @@ | ||
| #include "stack.h" | ||
| #include <stdbool.h> | ||
| #include <stdlib.h> | ||
|
|
||
| // структура обыкновенного элемента в стеке | ||
| typedef struct StackNode StackNode; | ||
|
|
||
| struct StackNode { | ||
| int value; | ||
| struct StackNode* next; | ||
| }; | ||
|
|
||
| // сам стек (структура содержащая указатель на первый элемент стека) | ||
| struct Stack { | ||
| struct StackNode* head; | ||
| }; | ||
|
|
||
| Stack* newStack(void) | ||
| { | ||
| Stack* stack = calloc(1, sizeof(*stack)); | ||
| return stack; | ||
| } | ||
|
|
||
| void push(Stack* stack, int value) | ||
| { | ||
| StackNode* node = malloc(sizeof(StackNode)); | ||
| node->value = value; | ||
| node->next = stack->head; | ||
| stack->head = node; | ||
| } | ||
|
|
||
| int pop(Stack* stack) | ||
| { | ||
| StackNode* oldNode = stack->head; | ||
| int res = oldNode->value; | ||
| stack->head = oldNode->next; | ||
| free(oldNode); | ||
| return res; | ||
| } | ||
|
|
||
| int peek(struct Stack* stack) | ||
| { | ||
| StackNode* headNode = stack->head; | ||
| int res = headNode->value; | ||
| return res; | ||
| } | ||
|
|
||
| bool isEmpty(Stack* stack) { return stack->head == NULL; } | ||
|
|
||
| void deleteStack(Stack* stack) | ||
yaprogrammer18-yanchi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| while (!isEmpty(stack)) { | ||
| pop(stack); | ||
| } | ||
| free(stack); | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.