Kursova

Check-in [69fc6d77ae]
Login

Check-in [69fc6d77ae]

Overview
Comment:Added .clang-format and formatted sources according to it
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA3-256: 69fc6d77ae325e61535490f60ae7ed7774b37e1b8c286275301b74f2c43b084a
User & Date: 4l1v3b33f on 2021-01-12 11:16:33
Other Links: manifest | tags
Context
2021-01-12
11:16
Added .clang-format and formatted sources according to it Leaf check-in: 69fc6d77ae user: 4l1v3b33f tags: trunk
11:11
Fixed whitespace check-in: ede199dcd5 user: 4l1v3b33f tags: trunk
Changes

Added .clang-format version [369111dec4].

























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: 'true'
AlignConsecutiveDeclarations: 'true'
AlignEscapedNewlines: Left
AlignOperands: 'true'
AlignTrailingComments: 'true'
AllowAllParametersOfDeclarationOnNextLine: 'true'
AllowShortBlocksOnASingleLine: 'false'
AllowShortCaseLabelsOnASingleLine: 'false'
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: 'false'
AllowShortLoopsOnASingleLine: 'false'
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: 'false'
AlwaysBreakTemplateDeclarations: 'Yes'
BinPackArguments: 'false'
BinPackParameters: 'false'
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Allman
BreakBeforeTernaryOperators: 'true'
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: 'true'
CompactNamespaces: 'false'
ConstructorInitializerAllOnOneLineOrOnePerLine: 'true'
Cpp11BracedListStyle: 'true'
DerivePointerAlignment: 'false'
DisableFormat: 'false'
FixNamespaceComments: 'true'
IncludeBlocks: Preserve
IndentCaseLabels: 'false'
IndentPPDirectives: AfterHash
IndentWrappedFunctionNames: 'false'
JavaScriptQuotes: Single
JavaScriptWrapImports: 'true'
KeepEmptyLinesAtTheStartOfBlocks: 'false'
NamespaceIndentation: Inner
PointerAlignment: Right
ReflowComments: 'true'
SortIncludes: 'true'
SortUsingDeclarations: 'true'
SpaceAfterCStyleCast: 'true'
SpaceAfterTemplateKeyword: 'false'
SpaceBeforeAssignmentOperators: 'true'
SpaceBeforeCpp11BracedList: 'true'
SpaceBeforeCtorInitializerColon: 'false'
SpaceBeforeInheritanceColon: 'false'
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: 'true'
SpaceInEmptyParentheses: 'false'
SpacesInAngles: 'false'
SpacesInCStyleCastParentheses: 'false'
SpacesInContainerLiterals: 'false'
SpacesInParentheses: 'false'
SpacesInSquareBrackets: 'false'
Standard: Auto
UseTab: Never

...

Modified src/main.cxx from [7f432818c7] to [ca8f7e069c].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15


16


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <iostream>
#include <iomanip>
#include <stack>
#include <array>

// Неободимо для поддержки Unicode
#ifdef _WIN32
#include <windows.h> // SetConsoleOutputCP
#else
#include <locale>
#endif

using std::cin, std::cout, std::endl, std::flush, std::setw;
using std::stack, std::tuple;



void f_rec(const size_t fun_count, const size_t max_recursion_depth, const size_t n = 1, const size_t depth = 0)


{
	cout << setw(depth) << "" << n << endl;

	if (depth >= max_recursion_depth)
		return;

	for (size_t i = 0; i < fun_count - 1; i++)
	{
		f_rec(fun_count, max_recursion_depth, (n + i) % fun_count + 1, depth + 1);
	}
}

void f_iter(const size_t fun_count, const size_t max_recursion_depth)
{
	using stack_item = tuple<size_t, size_t>;

	stack<stack_item> return_stack;
	return_stack.push({1, 0});

	while (!return_stack.empty())
	{
		auto [n, depth] = return_stack.top();
		return_stack.pop();

		stack<stack_item> queue;

		// BEGIN unmodified code
		cout << setw(depth) << "" << n << endl;

		if (depth >= max_recursion_depth)
			continue;

		for (size_t i = 0; i < fun_count - 1; i++)
		{
			queue.push({(n + i) % fun_count + 1, depth + 1});
		}
		// END unmodified code

		while (!queue.empty())
		{
			return_stack.push(queue.top());
			queue.pop();
		}
	}
}

int main()
{

	// Включаем поддержку Unicode
#ifdef _WIN32
	SetConsoleOutputCP(65001);
#else
	std::locale::global(std::locale(""));
#endif

	size_t fun_count;
	size_t max_recursion_depth;

	cout << u8"Кол-во функций: " << flush;
	cin >> fun_count;

	cout << u8"Макс. глубина рекурсии: " << flush;
	cin >> max_recursion_depth;

	cout << u8"Вывод рекурсивной функции:" << endl;
	f_rec(fun_count, max_recursion_depth);

	cout << u8"Вывод нерекурсивной функции:" << endl;
	f_iter(fun_count, max_recursion_depth);

	return 0;
}
|

|
|



|

|





>
>
|
>
>

|

|
|

|
|
|
|




|

|
|

|
|
|
|

|

|
|

|
|

|
|
|
|
|

|
|
|
|
|
|




<
|

|

|


|
|

|
|

|
|

|
|

|
|

|

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <array>
#include <iomanip>
#include <iostream>
#include <stack>

// Неободимо для поддержки Unicode
#ifdef _WIN32
#  include <windows.h> // SetConsoleOutputCP
#else
#  include <locale>
#endif

using std::cin, std::cout, std::endl, std::flush, std::setw;
using std::stack, std::tuple;

void f_rec(
    const size_t fun_count,
    const size_t max_recursion_depth,
    const size_t n     = 1,
    const size_t depth = 0)
{
  cout << setw(depth) << "" << n << endl;

  if (depth >= max_recursion_depth)
    return;

  for (size_t i = 0; i < fun_count - 1; i++)
  {
    f_rec(fun_count, max_recursion_depth, (n + i) % fun_count + 1, depth + 1);
  }
}

void f_iter(const size_t fun_count, const size_t max_recursion_depth)
{
  using stack_item = tuple<size_t, size_t>;

  stack<stack_item> return_stack;
  return_stack.push({1, 0});

  while (!return_stack.empty())
  {
    auto [n, depth] = return_stack.top();
    return_stack.pop();

    stack<stack_item> queue;

    // BEGIN unmodified code
    cout << setw(depth) << "" << n << endl;

    if (depth >= max_recursion_depth)
      continue;

    for (size_t i = 0; i < fun_count - 1; i++)
    {
      queue.push({(n + i) % fun_count + 1, depth + 1});
    }
    // END unmodified code

    while (!queue.empty())
    {
      return_stack.push(queue.top());
      queue.pop();
    }
  }
}

int main()
{

  // Включаем поддержку Unicode
#ifdef _WIN32
  SetConsoleOutputCP(65001);
#else
  std::locale::global(std::locale(""));
#endif

  size_t fun_count;
  size_t max_recursion_depth;

  cout << u8"Кол-во функций: " << flush;
  cin >> fun_count;

  cout << u8"Макс. глубина рекурсии: " << flush;
  cin >> max_recursion_depth;

  cout << u8"Вывод рекурсивной функции:" << endl;
  f_rec(fun_count, max_recursion_depth);

  cout << u8"Вывод нерекурсивной функции:" << endl;
  f_iter(fun_count, max_recursion_depth);

  return 0;
}