Заготовка CellularAutomaton
This commit is contained in:
5
lab1/CellularAutomaton.cpp
Normal file
5
lab1/CellularAutomaton.cpp
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#include "CellularAutomaton.h"
|
||||||
|
|
||||||
|
CellularAutomaton::CellularAutomaton(int width, int height) : m_fieldWidth(width), m_fieldHeight(height)
|
||||||
|
{
|
||||||
|
}
|
||||||
8
lab1/CellularAutomaton.h
Normal file
8
lab1/CellularAutomaton.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#pragma once
|
||||||
|
class CellularAutomaton
|
||||||
|
{
|
||||||
|
int m_fieldWidth, m_fieldHeight;
|
||||||
|
public:
|
||||||
|
CellularAutomaton(int width, int height);
|
||||||
|
};
|
||||||
|
|
||||||
@@ -1,9 +1,45 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
#include "CellularAutomaton.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
void clear() {
|
||||||
|
system("cls");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main()
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -127,10 +127,12 @@
|
|||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClCompile Include="CellularAutomaton.cpp" />
|
||||||
<ClCompile Include="io.cpp" />
|
<ClCompile Include="io.cpp" />
|
||||||
<ClCompile Include="lab1.cpp" />
|
<ClCompile Include="lab1.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="CellularAutomaton.h" />
|
||||||
<ClInclude Include="io.h" />
|
<ClInclude Include="io.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|||||||
@@ -21,10 +21,16 @@
|
|||||||
<ClCompile Include="io.cpp">
|
<ClCompile Include="io.cpp">
|
||||||
<Filter>Исходные файлы</Filter>
|
<Filter>Исходные файлы</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="CellularAutomaton.cpp">
|
||||||
|
<Filter>Исходные файлы</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="io.h">
|
<ClInclude Include="io.h">
|
||||||
<Filter>Файлы заголовков</Filter>
|
<Filter>Файлы заголовков</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="CellularAutomaton.h">
|
||||||
|
<Filter>Файлы заголовков</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user