LabWork05
This commit is contained in:
parent
b2124bf15a
commit
705c0faed1
@ -1,31 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34525.116
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{D8A4ACE0-0728-47AB-9F80-9EDA475782ED}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D8A4ACE0-0728-47AB-9F80-9EDA475782ED}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C1FC7C16-B9EC-4007-BD39-E6B47A89CE34}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3368BA78-2800-49EC-9A71-865DC3C2F15F}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,10 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,68 +0,0 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
// Класс компонента компьютера
|
||||
public class ComputerComponent
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Type { get; set; }
|
||||
|
||||
public ComputerComponent(string name, string type)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
}
|
||||
}
|
||||
|
||||
// АТД Очередь на основе массива
|
||||
public class CustomQueue
|
||||
{
|
||||
private ArrayList elements = new ArrayList();
|
||||
|
||||
public int Count { get { return elements.Count; } }
|
||||
|
||||
public void Enqueue(ComputerComponent component)
|
||||
{
|
||||
elements.Add(component);
|
||||
}
|
||||
|
||||
public ComputerComponent Dequeue()
|
||||
{
|
||||
if (elements.Count == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Queue is empty");
|
||||
}
|
||||
|
||||
ComputerComponent component = (ComputerComponent)elements[0];
|
||||
elements.RemoveAt(0);
|
||||
return component;
|
||||
}
|
||||
|
||||
public ComputerComponent Peek()
|
||||
{
|
||||
if (elements.Count == 0)
|
||||
{
|
||||
throw new InvalidOperationException("Queue is empty");
|
||||
}
|
||||
|
||||
return (ComputerComponent)elements[0];
|
||||
}
|
||||
}
|
||||
class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
CustomQueue queue = new CustomQueue();
|
||||
|
||||
// Добавление компонентов в очередь
|
||||
ComputerComponent cpu = new ComputerComponent("Intel Core i7", "CPU");
|
||||
ComputerComponent gpu = new ComputerComponent("Nvidia RTX 3080", "GPU");
|
||||
|
||||
queue.Enqueue(cpu);
|
||||
queue.Enqueue(gpu);
|
||||
|
||||
// Проверка совместимости компонентов в сборке
|
||||
Console.WriteLine("Первый компонент в очереди: {0} ({1})", queue.Peek().Name, queue.Peek().Type);
|
||||
Console.WriteLine("Извлечен компонент из очереди: {0} ({1})", queue.Dequeue().Name, queue.Dequeue().Type);
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
@ -1,113 +0,0 @@
|
||||
using System;
|
||||
|
||||
// Реализация АТД Очередь
|
||||
public class Queue<T>
|
||||
{
|
||||
private T[] elements;
|
||||
private int front, rear, size, capacity;
|
||||
|
||||
public Queue(int capacity)
|
||||
{
|
||||
this.capacity = capacity;
|
||||
elements = new T[capacity];
|
||||
front = size = 0;
|
||||
rear = capacity - 1;
|
||||
}
|
||||
|
||||
public void Enqueue(T item)
|
||||
{
|
||||
if (size == capacity)
|
||||
throw new Exception("Queue is full");
|
||||
rear = (rear + 1) % capacity;
|
||||
elements[rear] = item;
|
||||
size++;
|
||||
}
|
||||
|
||||
public T Dequeue()
|
||||
{
|
||||
if (size == 0)
|
||||
throw new Exception("Queue is empty");
|
||||
T item = elements[front];
|
||||
front = (front + 1) % capacity;
|
||||
size--;
|
||||
return item;
|
||||
}
|
||||
|
||||
// Реализация СД Массив
|
||||
public static void SelectionSort(int[] array)
|
||||
{
|
||||
for (int i = 0; i < array.Length - 1; i++)
|
||||
{
|
||||
int minIndex = i;
|
||||
for (int j = i + 1; j < array.Length; j++)
|
||||
{
|
||||
if (array[j] < array[minIndex])
|
||||
{
|
||||
minIndex = j;
|
||||
}
|
||||
}
|
||||
if (minIndex != i)
|
||||
{
|
||||
int temp = array[i];
|
||||
array[i] = array[minIndex];
|
||||
array[minIndex] = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Быстрая сортировка
|
||||
public static void QuickSort(int[] array, int left, int right)
|
||||
{
|
||||
if (left < right)
|
||||
{
|
||||
int pivot = Partition(array, left, right);
|
||||
QuickSort(array, left, pivot - 1);
|
||||
QuickSort(array, pivot + 1, right);
|
||||
}
|
||||
}
|
||||
|
||||
private static int Partition(int[] array, int left, int right)
|
||||
{
|
||||
int pivot = array[right];
|
||||
int i = left - 1;
|
||||
for (int j = left; j < right; j++)
|
||||
{
|
||||
if (array[j] < pivot)
|
||||
{
|
||||
i++;
|
||||
int temp = array[i];
|
||||
array[i] = array[j];
|
||||
array[j] = temp;
|
||||
}
|
||||
}
|
||||
int temp1 = array[i + 1];
|
||||
array[i + 1] = array[right];
|
||||
array[right] = temp1;
|
||||
return i + 1;
|
||||
}
|
||||
|
||||
public static void Main()
|
||||
{
|
||||
int[] array = { 64, 34, 25, 12, 22, 11, 90 };
|
||||
|
||||
// Сортировка выбором
|
||||
Console.WriteLine("Before selection sort:");
|
||||
foreach (var item in array) Console.Write(item + " ");
|
||||
SelectionSort(array);
|
||||
Console.WriteLine("\n\nAfter selection sort:");
|
||||
foreach (var item in array) Console.Write(item + " ");
|
||||
|
||||
// Быстрая сортировка
|
||||
Console.WriteLine("\n\nBefore quick sort:");
|
||||
foreach (var item in array) Console.Write(item + " ");
|
||||
QuickSort(array, 0, array.Length - 1);
|
||||
Console.WriteLine("\n\nAfter quick sort:");
|
||||
foreach (var item in array) Console.Write(item + " ");
|
||||
|
||||
// Использование Очереди
|
||||
Queue<int> queue = new Queue<int>(5);
|
||||
queue.Enqueue(10);
|
||||
queue.Enqueue(20);
|
||||
queue.Dequeue();
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.8.34525.116
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormsApp1", "WinFormsApp1\WinFormsApp1.csproj", "{50092433-6AF5-4E71-9559-079AE2F9901A}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{50092433-6AF5-4E71-9559-079AE2F9901A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{50092433-6AF5-4E71-9559-079AE2F9901A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{50092433-6AF5-4E71-9559-079AE2F9901A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{50092433-6AF5-4E71-9559-079AE2F9901A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {59C3FED6-0E53-4AF0-9E1B-5ACF902ED5CE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
39
WinFormsApp1/WinFormsApp1/Form1.Designer.cs
generated
39
WinFormsApp1/WinFormsApp1/Form1.Designer.cs
generated
@ -1,39 +0,0 @@
|
||||
namespace WinFormsApp1
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace WinFormsApp1
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,17 +0,0 @@
|
||||
namespace WinFormsApp1
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user