DeleteObjects
This commit is contained in:
parent
22dca98743
commit
9a203d7f80
200
OS/First.cpp
200
OS/First.cpp
@ -1,200 +0,0 @@
|
|||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cctype>
|
|
||||||
#include <string>
|
|
||||||
#include <cmath>
|
|
||||||
#include <set>
|
|
||||||
#include <map>
|
|
||||||
#include <ctime>
|
|
||||||
#include <chrono>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <queue>
|
|
||||||
using namespace std;
|
|
||||||
#define endl '\n'
|
|
||||||
#define endll cout << endl
|
|
||||||
#define LL_MAX 2223372036854775807
|
|
||||||
typedef long long ll;
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
|
|
||||||
class Stack {
|
|
||||||
private:
|
|
||||||
struct Node
|
|
||||||
{
|
|
||||||
Node* back;
|
|
||||||
T value;
|
|
||||||
};
|
|
||||||
Node* Head;
|
|
||||||
public:
|
|
||||||
Stack()
|
|
||||||
{
|
|
||||||
Head = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Add(T component)
|
|
||||||
{
|
|
||||||
Node* bk = Head;
|
|
||||||
Head = new Node;
|
|
||||||
Head->back = bk;
|
|
||||||
Head->value = component;
|
|
||||||
}
|
|
||||||
|
|
||||||
T Pop()
|
|
||||||
{
|
|
||||||
if (Head != nullptr)
|
|
||||||
{
|
|
||||||
Node* v = Head;
|
|
||||||
Head = Head->back;
|
|
||||||
T value = v->value;
|
|
||||||
delete(v);
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool isEmpty()
|
|
||||||
{
|
|
||||||
if (Head == nullptr)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
struct Arg {
|
|
||||||
public:
|
|
||||||
string Name;
|
|
||||||
string Type;
|
|
||||||
string Value;
|
|
||||||
|
|
||||||
Arg() {}
|
|
||||||
|
|
||||||
Arg(string n, string t, string v) : Name(n), Type(t), Value(v) {}
|
|
||||||
|
|
||||||
Arg(string n, string t) : Name(n), Type(t), Value("None") {}
|
|
||||||
};
|
|
||||||
|
|
||||||
class SysCall
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int ID;
|
|
||||||
string Name;
|
|
||||||
vector<Arg> Args;
|
|
||||||
|
|
||||||
SysCall(int id, string name, vector<Arg> args) : ID(id), Name(name), Args(args) {}
|
|
||||||
|
|
||||||
string toString()
|
|
||||||
{
|
|
||||||
string otv = "ID: " + to_string(ID) + "\t Name: " + Name + "\n";
|
|
||||||
for (Arg a : Args)
|
|
||||||
{
|
|
||||||
otv += "name: " + a.Name + "\t type: " + a.Type + "\t value: " + a.Value + "\n";
|
|
||||||
}
|
|
||||||
return otv;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class Kernel
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
vector<SysCall> Calls;
|
|
||||||
public:
|
|
||||||
Kernel()
|
|
||||||
{
|
|
||||||
Calls = vector<SysCall>({
|
|
||||||
SysCall(1, "A", vector<Arg>({
|
|
||||||
Arg("AB", "int")
|
|
||||||
})),
|
|
||||||
SysCall(2, "B", vector<Arg>({
|
|
||||||
Arg("AB", "int", "163"),
|
|
||||||
Arg("BA", "string", "145")})),
|
|
||||||
SysCall(3, "V", vector<Arg>({
|
|
||||||
Arg("BA", "string", "145"),
|
|
||||||
Arg("OT", "bool", "731"),
|
|
||||||
Arg("QA", "float", "921")
|
|
||||||
})),
|
|
||||||
SysCall(4, "ST", vector<Arg>({
|
|
||||||
Arg("A", "string", "45"),
|
|
||||||
Arg("O", "string", "71"),
|
|
||||||
Arg("Q", "double", "21")
|
|
||||||
})),
|
|
||||||
SysCall(5, "OP", vector<Arg>({
|
|
||||||
Arg("B", "string", "15"),
|
|
||||||
Arg("OGT", "bool", "731"),
|
|
||||||
Arg("QFA", "float", "921")
|
|
||||||
}))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowAll()
|
|
||||||
{
|
|
||||||
for (SysCall c : Calls)
|
|
||||||
{
|
|
||||||
cout << c.toString() << "\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Call(int id, Stack<Arg> stack)
|
|
||||||
{
|
|
||||||
cout << "Ñòàðò âûçîâà:" << endl;
|
|
||||||
for (auto it : Calls)
|
|
||||||
{
|
|
||||||
if (it.ID == id)
|
|
||||||
{
|
|
||||||
cout << "Âûçîâ " << it.Name << endl;
|
|
||||||
for (auto arg : it.Args)
|
|
||||||
{
|
|
||||||
if (stack.isEmpty())
|
|
||||||
{
|
|
||||||
cout << "Íåäîñòàòîê àðãóìåíòîâ ERROR" << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Arg a = stack.Pop();
|
|
||||||
if (arg.Type != a.Type)
|
|
||||||
{
|
|
||||||
cout << "Íåâåðíûé òèï äàííûõ Error \t Íàçâàíèå: " << it.Name << endl; return;
|
|
||||||
}
|
|
||||||
cout << "Àðãóìåíò: " << a.Type << " Çíà÷åíèå: " << a.Value << endl;
|
|
||||||
}
|
|
||||||
cout << "Âûçîâ âûïîëíåí óñïåøíî" << endl; return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cout << "Íåâåðíûé ID Error" << endl;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main1()
|
|
||||||
{
|
|
||||||
setlocale(LC_ALL, "Russian");
|
|
||||||
|
|
||||||
Kernel k;
|
|
||||||
|
|
||||||
endll;
|
|
||||||
Stack<Arg> S1;
|
|
||||||
S1.Add(Arg("AB", "int"));
|
|
||||||
k.Call(1, S1);
|
|
||||||
endll;
|
|
||||||
Stack<Arg> S3;
|
|
||||||
S3.Add(Arg("QA", "float", "921"));
|
|
||||||
S3.Add(Arg("OT", "bool", "731"));
|
|
||||||
S3.Add(Arg("BA", "string", "145"));
|
|
||||||
k.Call(3, S3);
|
|
||||||
endll;
|
|
||||||
Stack<Arg> S2;
|
|
||||||
S2.Add(Arg("QA", "float", "921"));
|
|
||||||
S2.Add(Arg("OT", "bool", "731"));
|
|
||||||
S2.Add(Arg("BA", "string", "145"));
|
|
||||||
k.Call(2, S2);
|
|
||||||
endll;
|
|
||||||
Stack<Arg> S4;
|
|
||||||
k.Call(4, S4);
|
|
||||||
endll;
|
|
||||||
Stack<Arg> S5;
|
|
||||||
k.Call(8, S5);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
31
OS/OS.sln
31
OS/OS.sln
@ -1,31 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.7.34009.444
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OS", "OS.vcxproj", "{2396AFD1-ABAB-4058-8A95-1699DD32E088}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|x64 = Debug|x64
|
|
||||||
Debug|x86 = Debug|x86
|
|
||||||
Release|x64 = Release|x64
|
|
||||||
Release|x86 = Release|x86
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Debug|x64.ActiveCfg = Debug|x64
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Debug|x64.Build.0 = Debug|x64
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Debug|x86.ActiveCfg = Debug|Win32
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Debug|x86.Build.0 = Debug|Win32
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Release|x64.ActiveCfg = Release|x64
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Release|x64.Build.0 = Release|x64
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Release|x86.ActiveCfg = Release|Win32
|
|
||||||
{2396AFD1-ABAB-4058-8A95-1699DD32E088}.Release|x86.Build.0 = Release|Win32
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {47E0F701-8EA9-4BEA-AADA-DF48244F5A0E}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
136
OS/OS.vcxproj
136
OS/OS.vcxproj
@ -1,136 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup Label="ProjectConfigurations">
|
|
||||||
<ProjectConfiguration Include="Debug|Win32">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|Win32">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>Win32</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Debug|x64">
|
|
||||||
<Configuration>Debug</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
<ProjectConfiguration Include="Release|x64">
|
|
||||||
<Configuration>Release</Configuration>
|
|
||||||
<Platform>x64</Platform>
|
|
||||||
</ProjectConfiguration>
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup Label="Globals">
|
|
||||||
<VCProjectVersion>17.0</VCProjectVersion>
|
|
||||||
<Keyword>Win32Proj</Keyword>
|
|
||||||
<ProjectGuid>{2396afd1-abab-4058-8a95-1699dd32e088}</ProjectGuid>
|
|
||||||
<RootNamespace>OS</RootNamespace>
|
|
||||||
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>true</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
|
||||||
<ConfigurationType>Application</ConfigurationType>
|
|
||||||
<UseDebugLibraries>false</UseDebugLibraries>
|
|
||||||
<PlatformToolset>v143</PlatformToolset>
|
|
||||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
|
||||||
<CharacterSet>Unicode</CharacterSet>
|
|
||||||
</PropertyGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
|
||||||
<ImportGroup Label="ExtensionSettings">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="Shared">
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
|
||||||
</ImportGroup>
|
|
||||||
<PropertyGroup Label="UserMacros" />
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
|
||||||
<ClCompile>
|
|
||||||
<WarningLevel>Level3</WarningLevel>
|
|
||||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
|
||||||
<SDLCheck>true</SDLCheck>
|
|
||||||
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
|
||||||
<ConformanceMode>true</ConformanceMode>
|
|
||||||
</ClCompile>
|
|
||||||
<Link>
|
|
||||||
<SubSystem>Console</SubSystem>
|
|
||||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
|
||||||
<OptimizeReferences>true</OptimizeReferences>
|
|
||||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
|
||||||
</Link>
|
|
||||||
</ItemDefinitionGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="First.cpp" />
|
|
||||||
<ClCompile Include="Second.cpp" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
|
||||||
<ImportGroup Label="ExtensionTargets">
|
|
||||||
</ImportGroup>
|
|
||||||
</Project>
|
|
@ -1,25 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<ItemGroup>
|
|
||||||
<Filter Include="Исходные файлы">
|
|
||||||
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
|
|
||||||
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Файлы заголовков">
|
|
||||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
|
||||||
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
|
|
||||||
</Filter>
|
|
||||||
<Filter Include="Файлы ресурсов">
|
|
||||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
|
||||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
|
||||||
</Filter>
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ClCompile Include="First.cpp">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="Second.cpp">
|
|
||||||
<Filter>Исходные файлы</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
|
155
OS/Second.cpp
155
OS/Second.cpp
@ -1,155 +0,0 @@
|
|||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
#include <iostream>
|
|
||||||
#include <vector>
|
|
||||||
#include <algorithm>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cctype>
|
|
||||||
#include <string>
|
|
||||||
#include <cmath>
|
|
||||||
#include <set>
|
|
||||||
#include <map>
|
|
||||||
#include <ctime>
|
|
||||||
#include <chrono>
|
|
||||||
#include <fstream>
|
|
||||||
#include <iomanip>
|
|
||||||
#include <queue>
|
|
||||||
using namespace std;
|
|
||||||
#define endl '\n'
|
|
||||||
#define endll cout << endl
|
|
||||||
#define LL_MAX 2223372036854775807
|
|
||||||
typedef long long ll;
|
|
||||||
|
|
||||||
int ALL_TIME = 100;
|
|
||||||
|
|
||||||
struct Laba {
|
|
||||||
public:
|
|
||||||
struct potok
|
|
||||||
{
|
|
||||||
double need;
|
|
||||||
vector<double> coords;
|
|
||||||
potok()
|
|
||||||
{
|
|
||||||
need = rand() % 20 + 1;
|
|
||||||
}
|
|
||||||
double add(double t)
|
|
||||||
{
|
|
||||||
if (t >= need)
|
|
||||||
{
|
|
||||||
coords.push_back(need);
|
|
||||||
int otv = need;
|
|
||||||
need = 0;
|
|
||||||
return otv;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
coords.push_back(t);
|
|
||||||
need -= t;
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool full()
|
|
||||||
{
|
|
||||||
if (need == 0)
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
struct process
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
vector<potok> Worker;
|
|
||||||
int count_potok = 0;
|
|
||||||
process()
|
|
||||||
{
|
|
||||||
count_potok = rand() % 5 + 1;
|
|
||||||
for (int i = 0; i < count_potok; i++)
|
|
||||||
{
|
|
||||||
Worker.emplace_back();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
vector<process> proc;
|
|
||||||
int count_proc;
|
|
||||||
int count_all_potok = 0;
|
|
||||||
int potok_max;
|
|
||||||
double kvant;
|
|
||||||
int timer = 0;
|
|
||||||
int count_kvant;
|
|
||||||
Laba()
|
|
||||||
{
|
|
||||||
count_kvant = 0;
|
|
||||||
count_proc = 5;
|
|
||||||
for (int i = 0; i < count_proc; i++)
|
|
||||||
{
|
|
||||||
proc.emplace_back();
|
|
||||||
count_all_potok += proc[i].count_potok;
|
|
||||||
}
|
|
||||||
potok_max = count_all_potok;
|
|
||||||
}
|
|
||||||
bool Kvant_time()
|
|
||||||
{
|
|
||||||
kvant = 30;
|
|
||||||
count_all_potok = potok_max;
|
|
||||||
for (int i = 0; i < count_proc; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < proc[i].count_potok; j++)
|
|
||||||
{
|
|
||||||
if (proc[i].Worker[j].full())
|
|
||||||
count_all_potok--;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (count_all_potok == 0)
|
|
||||||
return 0;
|
|
||||||
count_kvant++;
|
|
||||||
double time = (double)kvant / (double)count_all_potok;
|
|
||||||
for (int i = 0; i < count_proc && kvant > 0; i++)
|
|
||||||
{
|
|
||||||
for (int j = 0; j < proc[i].count_potok && kvant > 0; j++)
|
|
||||||
{
|
|
||||||
time = (double)kvant / (double)count_all_potok;
|
|
||||||
if (proc[i].Worker[j].full())
|
|
||||||
continue;
|
|
||||||
count_all_potok--;
|
|
||||||
double m = proc[i].Worker[j].add(time);
|
|
||||||
kvant -= m;
|
|
||||||
//cout << m << " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
void Paint()
|
|
||||||
{
|
|
||||||
cout << "Âûâîä âðåìåíè âûïîëíåíèÿ:" << endl;
|
|
||||||
for (int i = 0; i < count_proc; i++)
|
|
||||||
{
|
|
||||||
cout << "Ïðîöåññ " << i + 1 << endl << "Íîìåð êâàíòà:" << endl;
|
|
||||||
for (int j = 0; j < count_kvant; j++)
|
|
||||||
cout << j + 1<< "\t";
|
|
||||||
endll;
|
|
||||||
for (int j = 0; j < proc[i].count_potok; j++)
|
|
||||||
{
|
|
||||||
cout << "Ïîòîê íîìåð " << j + 1 << endl;
|
|
||||||
for (int k = 0; k < proc[i].Worker[j].coords.size(); k++)
|
|
||||||
{
|
|
||||||
cout << proc[i].Worker[j].coords[k] << "\t";
|
|
||||||
}
|
|
||||||
endll;
|
|
||||||
}
|
|
||||||
endll;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
srand(time(NULL));
|
|
||||||
setlocale(LC_ALL, "Russian");
|
|
||||||
cout.precision(3);
|
|
||||||
Laba l;
|
|
||||||
while (l.Kvant_time()) {}
|
|
||||||
l.Paint();
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
using System.Text;
|
|
||||||
|
|
||||||
Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
|
|
||||||
var enc1251 = Encoding.GetEncoding(1251);
|
|
||||||
|
|
||||||
System.Console.OutputEncoding = System.Text.Encoding.UTF8;
|
|
||||||
System.Console.InputEncoding = enc1251;
|
|
@ -1,10 +0,0 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
|
||||||
|
|
||||||
<PropertyGroup>
|
|
||||||
<OutputType>Exe</OutputType>
|
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
|
||||||
<Nullable>enable</Nullable>
|
|
||||||
</PropertyGroup>
|
|
||||||
|
|
||||||
</Project>
|
|
@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
|
||||||
# Visual Studio Version 17
|
|
||||||
VisualStudioVersion = 17.7.34009.444
|
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rebotica", "Rebotica.csproj", "{FFF4D9B9-1D85-4691-BBC2-BB054222ED65}"
|
|
||||||
EndProject
|
|
||||||
Global
|
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
|
||||||
Debug|Any CPU = Debug|Any CPU
|
|
||||||
Release|Any CPU = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
|
||||||
{FFF4D9B9-1D85-4691-BBC2-BB054222ED65}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{FFF4D9B9-1D85-4691-BBC2-BB054222ED65}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{FFF4D9B9-1D85-4691-BBC2-BB054222ED65}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{FFF4D9B9-1D85-4691-BBC2-BB054222ED65}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
|
||||||
HideSolutionNode = FALSE
|
|
||||||
EndGlobalSection
|
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
|
||||||
SolutionGuid = {83511A19-01FF-4CB7-9778-1361B46FCB7B}
|
|
||||||
EndGlobalSection
|
|
||||||
EndGlobal
|
|
Loading…
x
Reference in New Issue
Block a user