From 7e9540f10ce6d454b0cb0cb5f82b0b9462b5c1d1 Mon Sep 17 00:00:00 2001 From: Arity-T Date: Tue, 3 Dec 2024 14:14:43 +0300 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D0=BE=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B0=20CellularAutomaton?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lab1/CellularAutomaton.cpp | 5 +++++ lab1/CellularAutomaton.h | 8 ++++++++ lab1/lab1.cpp | 38 +++++++++++++++++++++++++++++++++++++- lab1/lab1.vcxproj | 2 ++ lab1/lab1.vcxproj.filters | 6 ++++++ 5 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 lab1/CellularAutomaton.cpp create mode 100644 lab1/CellularAutomaton.h diff --git a/lab1/CellularAutomaton.cpp b/lab1/CellularAutomaton.cpp new file mode 100644 index 0000000..79241b8 --- /dev/null +++ b/lab1/CellularAutomaton.cpp @@ -0,0 +1,5 @@ +#include "CellularAutomaton.h" + +CellularAutomaton::CellularAutomaton(int width, int height) : m_fieldWidth(width), m_fieldHeight(height) +{ +} diff --git a/lab1/CellularAutomaton.h b/lab1/CellularAutomaton.h new file mode 100644 index 0000000..7f2ece5 --- /dev/null +++ b/lab1/CellularAutomaton.h @@ -0,0 +1,8 @@ +#pragma once +class CellularAutomaton +{ + int m_fieldWidth, m_fieldHeight; +public: + CellularAutomaton(int width, int height); +}; + diff --git a/lab1/lab1.cpp b/lab1/lab1.cpp index 5e2b48a..e5d56bf 100644 --- a/lab1/lab1.cpp +++ b/lab1/lab1.cpp @@ -1,9 +1,45 @@ #include #include "io.h" +#include "CellularAutomaton.h" using namespace std; +void clear() { + system("cls"); +} + + int main() { - std::cout << "Hello World!\n"; + setlocale(LC_ALL, "Russian"); + + while (true) { + skipIter: + clear(); + + cout << "Выберите способ вычисления функции:\n" + "Запустить клеточный автомат (0)\n" + "Завершить работу (1)\n\n"; + + int actionId = inputNumber(0, 1); + + clear(); + + if (actionId == 1) { + cout << "Выйти из программы? (yes/no)\n"; + if (userApprove()) return 0; + goto skipIter; + } + + cout << "Укажите ширину поля (min 1): "; + int fieldWidth = inputNumber(1); + + cout << "Укажите высоту поля (min 1): "; + int fieldHeight = inputNumber(1); + + cout << "Укажите количество итераций (min 1): "; + int iterationsCount = inputNumber(1); + + CellularAutomaton(fieldWidth, fieldHeight); + } } \ No newline at end of file diff --git a/lab1/lab1.vcxproj b/lab1/lab1.vcxproj index 9d1e4c2..eb42dd4 100644 --- a/lab1/lab1.vcxproj +++ b/lab1/lab1.vcxproj @@ -127,10 +127,12 @@ + + diff --git a/lab1/lab1.vcxproj.filters b/lab1/lab1.vcxproj.filters index 19526f6..ec17398 100644 --- a/lab1/lab1.vcxproj.filters +++ b/lab1/lab1.vcxproj.filters @@ -21,10 +21,16 @@ Исходные файлы + + Исходные файлы + Файлы заголовков + + Файлы заголовков + \ No newline at end of file