diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f00c630 --- /dev/null +++ b/.clang-format @@ -0,0 +1,245 @@ +--- +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 +... diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..355e687 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,6 @@ +version: 2 +updates: + - package-ecosystem: github-actions + directory: / + schedule: + interval: "weekly" \ No newline at end of file diff --git a/.github/workflows/build-and-lint.yml b/.github/workflows/build-and-lint.yml new file mode 100644 index 0000000..7502182 --- /dev/null +++ b/.github/workflows/build-and-lint.yml @@ -0,0 +1,16 @@ +name: Build and lint + +on: + - push + - pull_request + +jobs: + build-and-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + - name: Install clang-format-18 + run: sudo apt update && sudo apt install -y clang-format-18 + - name: Check format + run: | + find . -path ./build -prune -o -type f -name '*.[c|h]' -print | xargs clang-format-18 --style=file --dry-run -Werror \ No newline at end of file diff --git a/11.09/src/1.c b/11.09/src/1.c index bf41392..eca30ef 100644 --- a/11.09/src/1.c +++ b/11.09/src/1.c @@ -1,5 +1,5 @@ -#include #include +#include int main(void) { diff --git a/11.09/src/2.c b/11.09/src/2.c index d33dbd4..f7b039f 100644 --- a/11.09/src/2.c +++ b/11.09/src/2.c @@ -1,5 +1,5 @@ -#include #include +#include int division(int x, int y); @@ -15,6 +15,7 @@ int division(int x, int y) res++; } } + else if (x >= 0 && y < 0) { while (x > y) { x += y; @@ -26,6 +27,7 @@ int division(int x, int y) res++; } } + else if (x < 0 && y > 0) { while (x < y) { x += y; @@ -37,6 +39,7 @@ int division(int x, int y) res++; } } + else if (x < 0 && y < 0) { while (x <= y) { x -= y; diff --git a/11.09/src/4.c b/11.09/src/4.c index b2d9da1..eb66b65 100644 --- a/11.09/src/4.c +++ b/11.09/src/4.c @@ -3,7 +3,7 @@ int main(void) { - int *sumsCount = malloc(28 * sizeof(int)); + int* sumsCount = malloc(28 * sizeof(int)); for (int i = 0; i < 10; i++) { for (int o = 0; o < 10; o++) { diff --git a/15.09/src/1.c b/15.09/src/1.c index e5f0148..b8da466 100644 --- a/15.09/src/1.c +++ b/15.09/src/1.c @@ -1,7 +1,7 @@ +#include #include #include #include -#include bool bracketsChecker(char* string) { diff --git a/15.09/src/2.c b/15.09/src/2.c index c803d82..8cf74d2 100644 --- a/15.09/src/2.c +++ b/15.09/src/2.c @@ -1,6 +1,6 @@ +#include #include #include -#include #define MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/15.09/src/3.c b/15.09/src/3.c index c0abb49..2bd0a0c 100644 --- a/15.09/src/3.c +++ b/15.09/src/3.c @@ -7,7 +7,7 @@ int main(void) int counter = 0; scanf("%d\n", &n); - int *array = malloc(n * sizeof(int)); + int* array = malloc(n * sizeof(int)); for (int i = 0; i < n; i++) { scanf("%d", &array[i]); } diff --git a/test_1/src/gnomeSort.c b/test_1/src/gnomeSort.c index b94b39e..b89e741 100644 --- a/test_1/src/gnomeSort.c +++ b/test_1/src/gnomeSort.c @@ -1,9 +1,9 @@ #include #include -int *gnomeSort(int *array, int arrayLen); +int* gnomeSort(int* array, int arrayLen); -int *gnomeSort(int *array, int arrayLen) +int* gnomeSort(int* array, int arrayLen) { int j = 2; int i = 1; @@ -27,17 +27,17 @@ int *gnomeSort(int *array, int arrayLen) return array; } -int main(void) +int main(void) { int n = 0; scanf("%d", &n); - int *array = calloc(n, sizeof(int)); + int* array = calloc(n, sizeof(int)); for (int i = 0; i < n; i++) { scanf("%d", &array[i]); } - int *sortedArray = gnomeSort(array, n); + int* sortedArray = gnomeSort(array, n); for (int i = 0; i < n; i++) { printf("%d\n", sortedArray[i]); diff --git a/test_1/src/palindrome.c b/test_1/src/palindrome.c index fd9af4c..c865cd9 100644 --- a/test_1/src/palindrome.c +++ b/test_1/src/palindrome.c @@ -1,14 +1,14 @@ -#include #include -#include +#include #include +#include -bool palindromeChecker(char *string, int strLen); -char *removeWhitespaces(char *string, int strLen); +bool palindromeChecker(char* string, int strLen); +char* removeWhitespaces(char* string, int strLen); -char *removeWhitespaces(char *string, int strLen) +char* removeWhitespaces(char* string, int strLen) { - char *newString = malloc(strLen * sizeof(char)); + char* newString = malloc(strLen * sizeof(char)); int p = 0; for (int i = 0; i < strLen; i++) { if (string[i] != ' ') { @@ -21,7 +21,7 @@ char *removeWhitespaces(char *string, int strLen) return newString; } -bool palindromeChecker(char *string, int strLen) +bool palindromeChecker(char* string, int strLen) { int fromAnotherBorder = strLen - 1; for (int i = 0; i < strLen / 2; i++) { @@ -33,7 +33,7 @@ bool palindromeChecker(char *string, int strLen) return true; } -int main(void) +int main(void) { int n = 0; scanf("%d\n", &n); @@ -41,7 +41,7 @@ int main(void) char string[n + 1]; fgets(string, n + 1, stdin); - char *cleanString = removeWhitespaces(string, strlen(string)); + char* cleanString = removeWhitespaces(string, strlen(string)); printf("%d\n", palindromeChecker(cleanString, strlen(cleanString)));