Fixed my old formatting and patched things that were left as-is due to burnout and laziness

This commit is contained in:
2024-12-06 15:14:33 +03:00
parent 02068890a5
commit 69d40c2dfb
7 changed files with 85 additions and 71 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,3 @@
.out
a.out
.ccls
.ccls-cache

View File

@@ -1,5 +1,4 @@
#include <iostream>
using namespace std;
int gcd_recur(int n1, int n2)
{
@@ -20,8 +19,11 @@ int gcd_recur(int n1, int n2)
int main()
{
setlocale(LC_ALL, "Russian");
int a, b;
cin >> a >> b;
cout << gcd_recur(a, b);
std::cout << "Введите два числа для определения НОД: ";
std::cin >> a >> b;
std::cout << "НОД: " << gcd_recur(a, b) << std::endl;
}

View File

@@ -1,5 +1,4 @@
#include <iostream>
using namespace std;
int fib(int n)
{
@@ -11,7 +10,11 @@ int fib(int n)
int main()
{
int n; cin >> n;
setlocale(LC_ALL, "Russian");
int n;
cout << fib(n);
std::cout << "Введите число n для определения числа Фибоначчи: ";
std::cin >> n;
std::cout << fib(n) << std::endl;
}

View File

@@ -1,12 +1,12 @@
#include <iostream>
using namespace std;
#include <cmath>
double root(int n)
{
double L, R, B;
L = 0; R = n;
while (fabs(R - L) > 0.00001)
while (std::fabs(R - L) > 0.00001)
{
B = (L + R) / 2;
@@ -25,7 +25,7 @@ double root_hf_div(double n, double L, double R)
{
double B;
if (fabs(R - L) < 0.00001)
if (std::fabs(R - L) < 0.00001)
{
return (L + R) / 2;
}
@@ -47,9 +47,11 @@ double root_hf_div(double n, double L, double R)
int main()
{
setlocale(LC_ALL, "Russian");
double n; cin >> n;
double n;
cout << "Обычный: " << root(n) << endl;
std::cout << "Введите число n для определения корня: ";
std::cin >> n;
cout << "Рекурсивный: " << root_hf_div(n, 1, n) << endl;
std::cout << "Обычный: " << root(n) << std::endl;
std::cout << "Рекурсивный: " << root_hf_div(n, 1, n) << std::endl;
}

View File

@@ -1,5 +1,4 @@
#include <iostream>
using namespace std;
int f(int n, int sum)
{
@@ -12,7 +11,11 @@ int f(int n, int sum)
int main()
{
int n; cin >> n;
setlocale(LC_ALL, "Russian");
int n;
cout << f(n, 0);
std::cout << "Введите число n для определения суммы его цифр: ";
std::cin >> n;
std::cout << "Сумма: " << f(n, 0);
}

View File

@@ -1,5 +1,4 @@
#include <iostream>
using namespace std;
int f(int n)
{
@@ -10,6 +9,11 @@ int f(int n)
int main()
{
int n; cin >> n;
cout << f(n);
setlocale(LC_ALL, "Russian");
int n;
std::cout << "Введите число n для определения значения функции Дейкстры: ";
std::cin >> n;
std::cout << "Значение функции Дейкстры: " << f(n) << std::endl;
}

View File

@@ -1,26 +1,26 @@
#include <iostream>
using namespace std;
void move(int a, int b, int c, int n)
{
if (n == 1)
{
cout << "from " << a << " to " << c << endl;
std::cout << "Из " << a << " в " << c << std::endl;
}
else
{
move(a, c, b, n - 1);
cout << "from " << a << " to " << c << endl;
std::cout << "Из " << a << " в " << c << std::endl;
move(b, a, c, n - 1);
}
}
int main()
{
setlocale(LC_ALL, "Russian");
int n;
cout << "Enter the amount of disks: "; cin >> n;
std::cout << "Количество дисков: ";
std::cin >> n;
move(1, 2, 3, n);
}