-
-
Save comenix/af7c424527c792c6eb3c2f41d65dcb64 to your computer and use it in GitHub Desktop.
My clang format file. In sample.cpp is sample output
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
BasedOnStyle: WebKit | |
AccessModifierOffset: -4 | |
AlignAfterOpenBracket: false | |
AlignConsecutiveAssignments: false | |
AlignEscapedNewlinesLeft: false | |
AlignOperands: false | |
AlignTrailingComments: false | |
AllowAllParametersOfDeclarationOnNextLine: true | |
AllowShortBlocksOnASingleLine: false | |
AllowShortCaseLabelsOnASingleLine: false | |
AllowShortFunctionsOnASingleLine: All | |
AllowShortIfStatementsOnASingleLine: false | |
AllowShortLoopsOnASingleLine: false | |
AlwaysBreakAfterDefinitionReturnType: None | |
AlwaysBreakBeforeMultilineStrings: false | |
AlwaysBreakTemplateDeclarations: false | |
BinPackArguments: true | |
BinPackParameters: true | |
BreakBeforeBinaryOperators: All | |
BreakBeforeBraces: Stroustrup | |
BreakBeforeTernaryOperators: true | |
BreakConstructorInitializersBeforeComma: true | |
ColumnLimit: 120 | |
CommentPragmas: '^ IWYU pragma:' | |
ConstructorInitializerAllOnOneLineOrOnePerLine: false | |
ConstructorInitializerIndentWidth: 4 | |
ContinuationIndentWidth: 4 | |
Cpp11BracedListStyle: false | |
DerivePointerAlignment: false | |
DisableFormat: false | |
ExperimentalAutoDetectBinPacking: false | |
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] | |
IndentCaseLabels: false | |
IndentWidth: 4 | |
IndentWrappedFunctionNames: false | |
KeepEmptyLinesAtTheStartOfBlocks: true | |
MacroBlockBegin: '' | |
MacroBlockEnd: '' | |
MaxEmptyLinesToKeep: 1 | |
NamespaceIndentation: Inner | |
ObjCBlockIndentWidth: 4 | |
ObjCSpaceAfterProperty: true | |
ObjCSpaceBeforeProtocolList: true | |
PenaltyBreakBeforeFirstCallParameter: 19 | |
PenaltyBreakComment: 300 | |
PenaltyBreakFirstLessLess: 120 | |
PenaltyBreakString: 1000 | |
PenaltyExcessCharacter: 1000000 | |
PenaltyReturnTypeOnItsOwnLine: 60 | |
PointerAlignment: Left | |
SpaceAfterCStyleCast: false | |
SpaceBeforeAssignmentOperators: true | |
SpaceBeforeParens: ControlStatements | |
SpaceInEmptyParentheses: false | |
SpacesBeforeTrailingComments: 1 | |
SpacesInAngles: false | |
SpacesInContainerLiterals: true | |
SpacesInCStyleCastParentheses: false | |
SpacesInParentheses: false | |
SpacesInSquareBrackets: false | |
Standard: Cpp03 | |
TabWidth: 4 | |
UseTab: Always |
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
#include <algorithm> | |
#include <cstdlib> | |
#include <ctime> | |
#include <functional> | |
#include <iostream> | |
#include <iterator> | |
template <typename T, int size> bool is_sorted(T(&array)[size]) | |
{ | |
return std::adjacent_find(array, array + size, std::greater<T>()) == array + size; | |
} | |
int main() | |
{ | |
std::srand(std::time(0)); | |
int list[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; | |
do { | |
std::random_shuffle(list, list + 9); | |
} while (is_sorted(list)); | |
int score = 0; | |
do { | |
std::cout << "Current list: "; | |
std::copy(list, list + 9, std::ostream_iterator<int>(std::cout, " ")); | |
int rev; | |
while (true) { | |
std::cout << "\nDigits to reverse? "; | |
std::cin >> rev; | |
if (rev > 1 && rev < 10) | |
break; | |
std::cout << "Please enter a value between 2 and 9."; | |
} | |
++score; | |
std::reverse(list, list + rev); | |
} while (!is_sorted(list)); | |
std::cout << "Congratulations, you sorted the list.\n" | |
<< "You needed " << score << " reversals." << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment