Лабораторная работа 8

This commit is contained in:
Tonb73 2024-05-13 10:10:22 +03:00
parent b60f29db2b
commit cfb42cde8d
6 changed files with 0 additions and 442 deletions

View File

@ -1 +0,0 @@
#include "Data_Structure.h"

View File

@ -1,42 +0,0 @@
//#include <stdio.h>
//#include <stdlib.h>
//
//#pragma once
//
//struct Node {
// int data;
// Node* next;
//};
//
//class Data_Structure
//{
//private:
// Node* head;
// struct Node {
// int data;
// Node* next;
// };
//public:
// Data_Structure(){
// head = NULL;
// }
// void addNode(int val){
// Node* newNode = new Node;
// newNode->data = val;
// newNode->next = head;
// head = newNode;
//
//
// }
// void printList() {
// Node* currentNode = head;
// while (currentNode->next != NULL) {
// printf("%d", currentNode->data);
// currentNode = currentNode->next;
//
// }
//
//
// }
//};
//

View File

@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lab_1", "Lab_1.vcxproj", "{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}"
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
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x64.ActiveCfg = Debug|x64
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x64.Build.0 = Debug|x64
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x86.ActiveCfg = Debug|Win32
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Debug|x86.Build.0 = Debug|Win32
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x64.ActiveCfg = Release|x64
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x64.Build.0 = Release|x64
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x86.ActiveCfg = Release|Win32
{B3B62C1B-E8D8-4038-8DFD-248406A48EE2}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FF15C0FB-D559-46A6-B4E8-E461B8F5C363}
EndGlobalSection
EndGlobal

View File

@ -1,139 +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>{b3b62c1b-e8d8-4038-8dfd-248406a48ee2}</ProjectGuid>
<RootNamespace>Lab1</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="Data_Structure.cpp" />
<ClCompile Include="Source.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Data_Structure.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -1,30 +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="Source.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="Data_Structure.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Data_Structure.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,199 +0,0 @@
/*
Âàðèàíò 4
ÀÒÄ - ÑÒÅÊ
ÑÄ - Îäíîñâÿçàííûé ñïèñîê
Îáúåêòíàÿ îáëàòü - Ñòóäåíòû, îáùèå äàííûå
Ñîðòèðîâêà ñëèÿíèåì, øåéêåðîì
*/
#include <stdio.h>
#include <stdlib.h>
#include "Data_Structure.h"
int unsorted_array[10] = { 2, 5, 1,8,3,4,7,6,9,0 };
int arr[10] = { 2, 5, 1,8,3,4,7,6,9,0 };
int n = 10;
void Buble_sort() {
for (int i = 0; i < n; i++) {
for (int j = n - 1; j > i; j--) {
if (arr[j - 1] > arr[j]) {
int temp = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp;
}
}
}
}
void Merge(int arr[], int begin, int end) {
int mid = begin + (end - begin) / 2;
int i = begin;
int j = mid + 1;
int d[11] = { 0 };
int k = 0;
while (i <= mid && j <= end) {
if (arr[i] <= arr[j]) {
d[k] = arr[i];
i++;
}
else {
d[k] = arr[j];
j++;
}
k++;
}
while (i <= mid) {
d[k] = arr[i];
k++;
i++;
}
while (j <= end) {
d[k] = arr[j];
k++;
j++;
}
for (i = 0; i < k; i++) {
arr[begin + i] = d[i];
}
}
void Merge_sort(int* arr, int left, int right) {
int temp = 0;
if (left < right) {
if (right - left == 1) {
if (arr[left] > arr[right]) {
temp = arr[left];
arr[left] = arr[right];
arr[right] = temp;
}
}
else {
Merge_sort(arr, left, (right - left) / 2);
Merge_sort(arr, left + (right - left) / 2 + 1, right);
Merge(arr, left, right);
}
}
}
void Shake_sort() {
int direction = 0;
int left = arr[0];
int left_index = 0;
int right = arr[n];
int right_index = n;
for (int _ = 0; _ < n - 1; _++) {
if (direction == 0) {
for (int i = left_index; i < right_index - 1; i++) {
if (arr[i] > arr[i + 1]) {
int temp = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = temp;
}
}
if (right != arr[right_index]) {
for (int i = n; i > 0; i--) {
if (arr[i] == right) {
right_index = i;
}
}
}
direction = 1;
}
else {
for (int j = right_index; j > left_index; j--) {
if (arr[j] < arr[j - 1]) {
int temp1 = arr[j];
arr[j] = arr[j - 1];
arr[j - 1] = temp1;
}
}
if (left != arr[left_index]) {
for (int i = 0; i < n; i++) {
if (arr[i] == left) {
left_index = i;
}
}
}
}
direction = 0;
}
}
void print_list() {
for (int i = 0; i < n; i++) {
printf("%d ", arr[i]);
}
printf("\n");
}
struct Node {
int student_year;
int student_group;
struct Node* next;
};
struct Node* first = NULL;
void s_addToHead(int year, int group) {
struct Node* NewNode = (struct Node*)malloc(sizeof(NewNode));
NewNode->student_year = year;
NewNode->student_group = group;
NewNode->next = first;
first = NewNode;
}
void s_deleteFromHead() {
struct Node* DelNode = first;
int val1 = DelNode->student_year;
int val2 = DelNode->student_group;
first = first->next;
printf("****|PI-%d, %d| - Deleted\n", val2, val1);
}
void s_print() {
struct Node* i = first;
while (i) {
printf("|PI-%d, %d|\n", i->student_group, i->student_year);
i = i->next;
}
}
int main() {
s_addToHead(2020, 12);
s_addToHead(2021, 13);
s_addToHead(2022, 14);
s_addToHead(2024, 15);
s_print();
printf("------------------------\n");
s_deleteFromHead();
s_print();
print_list();
Shake_sort();
//Merge_sort(arr, 0, n - 1);
print_list();
//Data_structure newStructure;
return 0;
}