-
Notifications
You must be signed in to change notification settings - Fork 0
Working with lesson_3_branch. #4
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
18
commits into
main
Choose a base branch
from
lesson_3_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
18 commits
Select commit
Hold shift + click to select a range
1f90b71
Added hw for 3rd lesson about compilation
yaprogrammer18-yanchi 733067a
Add three files from homework (brackets, zeros and strings)
yaprogrammer18-yanchi 9729fb8
Delete dir with useless files in order not to be messed up
yaprogrammer18-yanchi ee719f3
Remove mistakes from files of hw
yaprogrammer18-yanchi 0b92d9b
Rename and remove files
yaprogrammer18-yanchi 0ae9722
Fix mistakes in all hw
yaprogrammer18-yanchi cc9c73c
Fix mistakes in zeros and strings, still think about bracket balance
yaprogrammer18-yanchi d2a3a74
Fix bracket balance. Now you can put as many symbols as you want
yaprogrammer18-yanchi 972ebc4
Fix brackets balancegit add oneStringInAnother.c !
yaprogrammer18-yanchi 4fb61a2
Fix bracket balance again
yaprogrammer18-yanchi 4bf6e87
Merge branch 'lesson_3_branch' of github.com:yaprogrammer18-yanchi/C_…
yaprogrammer18-yanchi 922b6ec
Finish working with bracketBalance.c
yaprogrammer18-yanchi 13568ea
Use clang-format for bracketBalance.c
yaprogrammer18-yanchi fafb969
add clang-format config
yaprogrammer18-yanchi b6f3179
add clang-format config just need to commit it one more time
yaprogrammer18-yanchi c03d67a
formatted files
yaprogrammer18-yanchi e17da74
Add cmake
yaprogrammer18-yanchi b85c2f8
Add Cmake
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
| 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/CompilationProcess) | ||
|
|
||
| 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,3 @@ | ||
| add_executable(braketBalance bracketBalance.c) | ||
| add_executable(oneStringInAnother oneStringInAnother.c) | ||
| add_executable(zerosInMassive zerosInMassive.c) |
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,61 @@ | ||
| #include <stdbool.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| bool checkBrackets(char* stringWithBrackets, int len) | ||
| { | ||
| if (len == 0) { | ||
| return false; | ||
| } | ||
| // специальный счетчик, "(" это +1 ")" это -1. Если скобочная посл-ть | ||
| // правильная, counter == 0 | ||
| int counter = 0; | ||
| for (int i = 0; i < len; i++) { | ||
| if (stringWithBrackets[i] == '(') { | ||
| counter++; | ||
| } | ||
| if (stringWithBrackets[i] == ')') { | ||
| counter--; | ||
| } | ||
| if (counter < 0) { | ||
| break; | ||
| } | ||
| } | ||
| if (counter == 0) { | ||
| return true; | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| int main() | ||
| { | ||
| // подразумеватся, что пользователь может ввести не только скобки и в кол-ве | ||
| // символов он должен указать всё кол-во символов включая скобки и не скобки. | ||
| int len = 0; | ||
| printf("Введите, сколько символов Вы хотите ввести, закончите ввод, нажав " | ||
| "enter\n"); | ||
| printf("На следующей строке введите скобочную последовательность\n"); | ||
| scanf("%d", &len); | ||
| // отловим этот '\n' | ||
| getchar(); | ||
| char* stringWithBrackets = malloc(len * sizeof(char)); | ||
| // счетчик чтобы считать кол-во скобок | ||
| int counter = 0; | ||
| for (int i = 0; i < len; i++) { | ||
| char tmp = ' '; | ||
| scanf("%c", &tmp); | ||
| if (tmp == ')' || tmp == '(') { | ||
| stringWithBrackets[counter] = tmp; | ||
| ++counter; | ||
| } | ||
| } | ||
| bool isCorrect = checkBrackets(stringWithBrackets, counter); | ||
| if (isCorrect) { | ||
| printf("Скобочная последовательность правильная\n"); | ||
| } else { | ||
| printf("Скобочная последовательность неправильная или не было введено ни " | ||
| "одной скобки\n"); | ||
| } | ||
| free(stringWithBrackets); | ||
| return 0; | ||
| } |
|
Collaborator
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. Пусть уже будет. |
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,28 @@ | ||
| #include <stdbool.h> | ||
| #include <stdio.h> | ||
| #include <stdlib.h> | ||
|
|
||
| int main() | ||
| { | ||
| char biggerString[] = "hellohellhellolllhello"; | ||
| char smallerString[] = "hello"; | ||
| size_t lenForBiggerString = sizeof(biggerString) / sizeof(char) - 1; | ||
| size_t lenForSmallerString = sizeof(smallerString) / sizeof(char) - 1; | ||
| int entryCounter = 0; | ||
| // i - индекс эл-та с которого будем рассматривать большую строку | ||
| for (unsigned i = 0; i <= lenForBiggerString - lenForSmallerString; i++) { | ||
| bool flag = true; | ||
| for (unsigned j = 0; j < lenForSmallerString; j++) { | ||
| if (biggerString[i + j] != smallerString[j]) { | ||
| flag = false; | ||
| break; | ||
| } | ||
| } | ||
| if (flag) { | ||
| ++entryCounter; | ||
| } | ||
| } | ||
| printf("%d\n", entryCounter); | ||
| return 0; | ||
| } | ||
| // Должно вывести 3 |
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,19 @@ | ||
| #include <stdio.h> | ||
|
|
||
| int main() | ||
| { | ||
| // пусть массив задан в программе | ||
| int arrayWithNumbers[] = { 0, 1, 3, 0, 6, 0, 7, 4, 6, 2, 0, 0 }; | ||
| int zeroCounter = 0; | ||
| size_t lengthOfArray = sizeof(arrayWithNumbers) / sizeof(int); | ||
|
|
||
| for (int i = 0; i < lengthOfArray; i++) { | ||
| if (arrayWithNumbers[i] == 0) { | ||
| ++zeroCounter; | ||
| } | ||
| } | ||
| printf("%d\n", zeroCounter); | ||
| return 0; | ||
| } | ||
|
|
||
| // выводит 5 - кол-во нулей |
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.
Зачтено.