From 6ac5101d6cc8f36a8f2cee669eece78fdab5c8e0 Mon Sep 17 00:00:00 2001 From: Zakhar Khomenkov Date: Sun, 12 Mar 2023 23:39:43 +0300 Subject: [PATCH 1/4] =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=83=20?= =?UTF-8?q?=D1=81=D0=B4=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StaticMath/AllLibs/AllLibs.cpp | 67 ++++++++ StaticMath/AllLibs/AllLibs.vcxproj | 152 ++++++++++++++++++ .../ConsoleApplication1.vcxproj | 136 ++++++++++++++++ .../ConsoleApplication1/MathClient2.cpp | 35 ++++ StaticMath/DynamicLib/DynMerg.cpp | 50 ++++++ StaticMath/DynamicLib/DynMerg.h | 7 + StaticMath/DynamicLib/DynamicLib.vcxproj | 138 ++++++++++++++++ StaticMath/MathClient/MathClient.cpp | 24 +++ StaticMath/MathClient/MathClient.vcxproj | 144 +++++++++++++++++ StaticMath/MathClient3/MathClient3.cpp | 24 +++ StaticMath/MathClient3/MathClient3.vcxproj | 147 +++++++++++++++++ StaticMath/MathLibrary/MathLibrary.cpp | 52 ++++++ StaticMath/MathLibrary/MathLibrary.h | 4 + StaticMath/MathLibrary/MathLibrary.vcxproj | 143 ++++++++++++++++ StaticMath/StaticMath.sln | 81 ++++++++++ 15 files changed, 1204 insertions(+) create mode 100644 StaticMath/AllLibs/AllLibs.cpp create mode 100644 StaticMath/AllLibs/AllLibs.vcxproj create mode 100644 StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj create mode 100644 StaticMath/ConsoleApplication1/MathClient2.cpp create mode 100644 StaticMath/DynamicLib/DynMerg.cpp create mode 100644 StaticMath/DynamicLib/DynMerg.h create mode 100644 StaticMath/DynamicLib/DynamicLib.vcxproj create mode 100644 StaticMath/MathClient/MathClient.cpp create mode 100644 StaticMath/MathClient/MathClient.vcxproj create mode 100644 StaticMath/MathClient3/MathClient3.cpp create mode 100644 StaticMath/MathClient3/MathClient3.vcxproj create mode 100644 StaticMath/MathLibrary/MathLibrary.cpp create mode 100644 StaticMath/MathLibrary/MathLibrary.h create mode 100644 StaticMath/MathLibrary/MathLibrary.vcxproj create mode 100644 StaticMath/StaticMath.sln diff --git a/StaticMath/AllLibs/AllLibs.cpp b/StaticMath/AllLibs/AllLibs.cpp new file mode 100644 index 0000000..9b115cd --- /dev/null +++ b/StaticMath/AllLibs/AllLibs.cpp @@ -0,0 +1,67 @@ +#include +#include +#include "MathLibrary.h" +#include +#include "DynMerg.h" + +int main() +{ + srand(time(NULL)); + printf("first array\n"); + printf("\n"); + int *a; + a = new int[8]; + for (int i = 0; i < 8; i++) + a[i] = rand() % 20 - 10; + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + merge(a, 8); + printf("array sorted with static lib\n"); + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + printf("\n"); + printf("second array\n"); + printf("\n"); + for (int i = 0; i < 8; i++) + a[i] = rand() % 20 - 10; + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + + typedef int (CALLBACK* DLLFUNC) (int*, int); + HINSTANCE load; + DLLFUNC Dllfunc; + load = LoadLibrary("DynamicLib"); + if (load != nullptr) + { + Dllfunc = (DLLFUNC)GetProcAddress(load, "mergeD"); + if (Dllfunc != nullptr) + { + Dllfunc(a, 8); + } + FreeLibrary(load); + } + printf("array sorted with explicit dynamic lib\n"); + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + printf("\n"); + printf("third array\n"); + printf("\n"); + for (int i = 0; i < 8; i++) + a[i] = rand() % 20 - 10; + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + + mergeD(a, 8); + + printf("array sorted with implicit dynamic lib\n"); + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + delete[] a; + return 0; +} \ No newline at end of file diff --git a/StaticMath/AllLibs/AllLibs.vcxproj b/StaticMath/AllLibs/AllLibs.vcxproj new file mode 100644 index 0000000..a867ee1 --- /dev/null +++ b/StaticMath/AllLibs/AllLibs.vcxproj @@ -0,0 +1,152 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {bdbe7d2c-ac32-4c9f-988e-8a6e198fe848} + AllLibs + 10.0 + + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + Application + true + v143 + MultiByte + + + Application + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + ..\$(IntDir);%(AdditionalLibraryDirectories) + DynamicLib.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + true + true + ..\$(IntDir);%(AdditionalLibraryDirectories) + DynamicLib.lib;%(AdditionalDependencies) + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + ..\$(IntDir);%(AdditionalLibraryDirectories) + DynamicLib.lib;%(AdditionalDependencies) + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + true + true + ..\$(IntDir);%(AdditionalLibraryDirectories) + DynamicLib.lib;%(AdditionalDependencies) + + + + + + + + {30d05401-eeee-45f0-8781-45dffb51cf98} + + + + + + \ No newline at end of file diff --git a/StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj b/StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj new file mode 100644 index 0000000..ce2c14f --- /dev/null +++ b/StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj @@ -0,0 +1,136 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {e2d48b79-10f7-45fc-a2bc-ff453378c53d} + ConsoleApplication1 + 10.0 + MathClient2 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + + + + \ No newline at end of file diff --git a/StaticMath/ConsoleApplication1/MathClient2.cpp b/StaticMath/ConsoleApplication1/MathClient2.cpp new file mode 100644 index 0000000..ed5cfd9 --- /dev/null +++ b/StaticMath/ConsoleApplication1/MathClient2.cpp @@ -0,0 +1,35 @@ +#include +#include +#include +int main() +{ + srand(time(NULL)); + int* a; + a = new int[8]; + for (int i = 0; i < 8; i++) + a[i] = rand() % 20 - 10; + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + + + typedef int (CALLBACK* DLLFUNC) (int*, int); + HINSTANCE load; + DLLFUNC Dllfunc; + load = LoadLibrary(L"DynamicLib.dll"); + if (load != nullptr) + { + Dllfunc = (DLLFUNC)GetProcAddress(load, "mergeD"); + if (Dllfunc != nullptr) + { + Dllfunc(a, 8); + } + FreeLibrary(load); + } + printf("array sorted with explicit dynamic lib\n"); + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + delete[]a; + return 0; +} diff --git a/StaticMath/DynamicLib/DynMerg.cpp b/StaticMath/DynamicLib/DynMerg.cpp new file mode 100644 index 0000000..4201971 --- /dev/null +++ b/StaticMath/DynamicLib/DynMerg.cpp @@ -0,0 +1,50 @@ + +#include +#include +extern "C" __declspec(dllexport) void mergeD(int* a, int n) +{ + int mid = n / 2; + if (n % 2 == 1) + mid++; + int h = 1; + + int* c = (int*)malloc(n * sizeof(int)); + int step; + while (h < n) + { + step = h; + int i = 0; + int j = mid; + int k = 0; + while (step <= mid) + { + while ((i < step) && (j < n) && (j < (mid + step))) + { + if (a[i] < a[j]) + { + c[k] = a[i]; + i++; k++; + } + else { + c[k] = a[j]; + j++; k++; + } + } + while (i < step) + { + c[k] = a[i]; + i++; k++; + } + while ((j < (mid + step)) && (j < n)) + { + c[k] = a[j]; + j++; k++; + } + step = step + h; + } + h = h * 2; + + for (i = 0; i < n; i++) + a[i] = c[i]; + } +} \ No newline at end of file diff --git a/StaticMath/DynamicLib/DynMerg.h b/StaticMath/DynamicLib/DynMerg.h new file mode 100644 index 0000000..2bbe0a1 --- /dev/null +++ b/StaticMath/DynamicLib/DynMerg.h @@ -0,0 +1,7 @@ +#pragma once +#ifdef SORTDYNAMIC_EXPORT +#define SORTDYNAMIC_API __declspec(dllexport) +#else +#define SORTDYNAMIC_API __declspec(dllimport) +#endif +extern "C" __declspec(dllexport) void mergeD(int* , int ); diff --git a/StaticMath/DynamicLib/DynamicLib.vcxproj b/StaticMath/DynamicLib/DynamicLib.vcxproj new file mode 100644 index 0000000..7041cd4 --- /dev/null +++ b/StaticMath/DynamicLib/DynamicLib.vcxproj @@ -0,0 +1,138 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {0343aedf-2efb-4d29-9571-c2c47c935c86} + DynamicLib + 10.0 + + + + DynamicLibrary + true + v143 + MultiByte + + + DynamicLibrary + false + v143 + true + MultiByte + + + DynamicLibrary + true + v143 + MultiByte + + + DynamicLibrary + false + v143 + true + MultiByte + + + + + + + + + + + + + + + + + + + + + + Level3 + true + SORTDYNAMIC_EXPORT + true + + + Console + true + + + + + Level3 + true + true + true + SORTDYNAMIC_EXPORT + true + + + Console + true + true + true + + + + + Level3 + true + SORTDYNAMIC_EXPORT + true + + + Console + true + + + + + Level3 + true + true + true + SORTDYNAMIC_EXPORT + true + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/StaticMath/MathClient/MathClient.cpp b/StaticMath/MathClient/MathClient.cpp new file mode 100644 index 0000000..3cf56cd --- /dev/null +++ b/StaticMath/MathClient/MathClient.cpp @@ -0,0 +1,24 @@ + +#include +#include +#include "MathLibrary.h" + +int main() +{ + srand(time(NULL)); + int* a; + a = new int[8]; + for (int i = 0; i < 8; i++) + a[i] = rand() % 20 - 10; + + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + merge(a, 8); + printf("static\n"); + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + delete[] a; + return 0; +} \ No newline at end of file diff --git a/StaticMath/MathClient/MathClient.vcxproj b/StaticMath/MathClient/MathClient.vcxproj new file mode 100644 index 0000000..b95e2cd --- /dev/null +++ b/StaticMath/MathClient/MathClient.vcxproj @@ -0,0 +1,144 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {585dc573-7a02-431f-86c6-60dbe17c2539} + MathClient + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + Level3 + true + _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) + + + Console + true + + + + + Level3 + true + true + true + NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) + + + Console + true + true + true + + + + + + + + {30d05401-eeee-45f0-8781-45dffb51cf98} + + + + + + \ No newline at end of file diff --git a/StaticMath/MathClient3/MathClient3.cpp b/StaticMath/MathClient3/MathClient3.cpp new file mode 100644 index 0000000..60b04a3 --- /dev/null +++ b/StaticMath/MathClient3/MathClient3.cpp @@ -0,0 +1,24 @@ +#include +#include +#include +#include "DynMerg.h" +int main() +{ + srand(time(NULL)); + int* a; + a = new int[8]; + for (int i = 0; i < 8; i++) + a[i] = rand() % 20 - 10; + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + + mergeD(a, 8); + + printf("array sorted with implicit dynamic lib\n"); + for (int i = 0; i < 8; i++) + printf("%d ", a[i]); + printf("\n"); + delete[]a; + return 0; +} diff --git a/StaticMath/MathClient3/MathClient3.vcxproj b/StaticMath/MathClient3/MathClient3.vcxproj new file mode 100644 index 0000000..ef5652d --- /dev/null +++ b/StaticMath/MathClient3/MathClient3.vcxproj @@ -0,0 +1,147 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {28f40427-d4a6-482e-a1b8-7a13fde0e5a2} + MathClient3 + 10.0 + + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + Application + true + v143 + Unicode + + + Application + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + SORTDYNAMIC_EXPORT + true + C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + DynamicLib.lib;%(AdditionalDependencies) + ..\$(IntDir);%(AdditionalLibraryDirectories) + + + + + Level3 + true + true + true + SORTDYNAMIC_EXPORT + true + C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + true + true + DynamicLib.lib;%(AdditionalDependencies) + ..\$(IntDir);%(AdditionalLibraryDirectories) + + + + + Level3 + true + SORTDYNAMIC_EXPORT + true + C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + DynamicLib.lib;%(AdditionalDependencies) + ..\$(IntDir);%(AdditionalLibraryDirectories) + + + + + Level3 + true + true + true + SORTDYNAMIC_EXPORT + true + C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) + + + Console + true + true + true + DynamicLib.lib;%(AdditionalDependencies) + ..\$(IntDir);%(AdditionalLibraryDirectories) + + + + + + + + + \ No newline at end of file diff --git a/StaticMath/MathLibrary/MathLibrary.cpp b/StaticMath/MathLibrary/MathLibrary.cpp new file mode 100644 index 0000000..e428d33 --- /dev/null +++ b/StaticMath/MathLibrary/MathLibrary.cpp @@ -0,0 +1,52 @@ + + +#include "MathLibrary.h" +#include +#include + +void merge(int* a, int n) +{ + int mid = n / 2; + if (n % 2 == 1) + mid++; + int h = 1; + int* c = (int*)malloc(n * sizeof(int)); + int step; + while (h < n) + { + step = h; + int i = 0; + int j = mid; + int k = 0; + while (step <= mid) + { + while ((i < step) && (j < n) && (j < (mid + step))) + { + if (a[i] < a[j]) + { + c[k] = a[i]; + i++; k++; + } + else { + c[k] = a[j]; + j++; k++; + } + } + while (i < step) + { + c[k] = a[i]; + i++; k++; + } + while ((j < (mid + step)) && (j < n)) + { + c[k] = a[j]; + j++; k++; + } + step = step + h; + } + h = h * 2; + + for (i = 0; i < n; i++) + a[i] = c[i]; + } +} \ No newline at end of file diff --git a/StaticMath/MathLibrary/MathLibrary.h b/StaticMath/MathLibrary/MathLibrary.h new file mode 100644 index 0000000..3f1bcec --- /dev/null +++ b/StaticMath/MathLibrary/MathLibrary.h @@ -0,0 +1,4 @@ + +#pragma once + +void merge(int*, int); diff --git a/StaticMath/MathLibrary/MathLibrary.vcxproj b/StaticMath/MathLibrary/MathLibrary.vcxproj new file mode 100644 index 0000000..0884f75 --- /dev/null +++ b/StaticMath/MathLibrary/MathLibrary.vcxproj @@ -0,0 +1,143 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 16.0 + Win32Proj + {30d05401-eeee-45f0-8781-45dffb51cf98} + MathLibrary + 10.0 + StaticLib + + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + StaticLibrary + true + v143 + Unicode + + + StaticLibrary + false + v143 + true + Unicode + + + + + + + + + + + + + + + + + + + + + + Level3 + true + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + + + true + + + + + Level3 + true + true + true + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + + + true + true + true + + + + + Level3 + true + _DEBUG;_LIB;%(PreprocessorDefinitions) + true + + + + + true + + + + + Level3 + true + true + true + NDEBUG;_LIB;%(PreprocessorDefinitions) + true + + + + + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/StaticMath/StaticMath.sln b/StaticMath/StaticMath.sln new file mode 100644 index 0000000..11da1b8 --- /dev/null +++ b/StaticMath/StaticMath.sln @@ -0,0 +1,81 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32929.385 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathLibrary", "MathLibrary\MathLibrary.vcxproj", "{30D05401-EEEE-45F0-8781-45DFFB51CF98}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathClient", "MathClient\MathClient.vcxproj", "{585DC573-7A02-431F-86C6-60DBE17C2539}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicLib", "DynamicLib\DynamicLib.vcxproj", "{0343AEDF-2EFB-4D29-9571-C2C47C935C86}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathClient2", "ConsoleApplication1\ConsoleApplication1.vcxproj", "{E2D48B79-10F7-45FC-A2BC-FF453378C53D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathClient3", "MathClient3\MathClient3.vcxproj", "{28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllLibs", "AllLibs\AllLibs.vcxproj", "{BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}" +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 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Debug|x64.ActiveCfg = Debug|x64 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Debug|x64.Build.0 = Debug|x64 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Debug|x86.ActiveCfg = Debug|Win32 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Debug|x86.Build.0 = Debug|Win32 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Release|x64.ActiveCfg = Release|x64 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Release|x64.Build.0 = Release|x64 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Release|x86.ActiveCfg = Release|Win32 + {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Release|x86.Build.0 = Release|Win32 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x64.ActiveCfg = Debug|x64 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x64.Build.0 = Debug|x64 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x86.ActiveCfg = Debug|Win32 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x86.Build.0 = Debug|Win32 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x64.ActiveCfg = Release|x64 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x64.Build.0 = Release|x64 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x86.ActiveCfg = Release|Win32 + {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x86.Build.0 = Release|Win32 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Debug|x64.ActiveCfg = Debug|x64 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Debug|x64.Build.0 = Debug|x64 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Debug|x86.ActiveCfg = Debug|Win32 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Debug|x86.Build.0 = Debug|Win32 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Release|x64.ActiveCfg = Release|x64 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Release|x64.Build.0 = Release|x64 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Release|x86.ActiveCfg = Release|Win32 + {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Release|x86.Build.0 = Release|Win32 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x64.ActiveCfg = Debug|x64 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x64.Build.0 = Debug|x64 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x86.ActiveCfg = Debug|Win32 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x86.Build.0 = Debug|Win32 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x64.ActiveCfg = Release|x64 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x64.Build.0 = Release|x64 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x86.ActiveCfg = Release|Win32 + {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x86.Build.0 = Release|Win32 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x64.ActiveCfg = Debug|x64 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x64.Build.0 = Debug|x64 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x86.ActiveCfg = Debug|Win32 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x86.Build.0 = Debug|Win32 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x64.ActiveCfg = Release|x64 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x64.Build.0 = Release|x64 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x86.ActiveCfg = Release|Win32 + {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x86.Build.0 = Release|Win32 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Debug|x64.ActiveCfg = Debug|x64 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Debug|x64.Build.0 = Debug|x64 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Debug|x86.ActiveCfg = Debug|Win32 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Debug|x86.Build.0 = Debug|Win32 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Release|x64.ActiveCfg = Release|x64 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Release|x64.Build.0 = Release|x64 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Release|x86.ActiveCfg = Release|Win32 + {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {38BC51DA-2C71-49C7-A65B-8978FB3BF262} + EndGlobalSection +EndGlobal -- GitLab From d36d2749f0d534e7029251f22e048ae6e2c846a1 Mon Sep 17 00:00:00 2001 From: Zakhar Khomenkov Date: Tue, 14 Mar 2023 16:27:14 +0300 Subject: [PATCH 2/4] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StaticMath/AllLibs/AllLibs.cpp | 40 +++++++------- StaticMath/DynamicLib/DynMerg.cpp | 69 ++++++++---------------- StaticMath/DynamicLib/DynMerg.h | 8 +-- StaticMath/DynamicLib/DynamicLib.vcxproj | 8 +-- StaticMath/MathLibrary/MathLibrary.cpp | 64 +++++++--------------- StaticMath/MathLibrary/MathLibrary.h | 1 - StaticMath/StaticMath.sln | 32 +---------- 7 files changed, 72 insertions(+), 150 deletions(-) diff --git a/StaticMath/AllLibs/AllLibs.cpp b/StaticMath/AllLibs/AllLibs.cpp index 9b115cd..8b02932 100644 --- a/StaticMath/AllLibs/AllLibs.cpp +++ b/StaticMath/AllLibs/AllLibs.cpp @@ -2,31 +2,37 @@ #include #include "MathLibrary.h" #include -#include "DynMerg.h" +#include "../DynamicLib/DynMerg.h" int main() { - srand(time(NULL)); + int n = 0; + while ((n <= 0) || (n >= 10)) + { + printf("input length of array\n"); + scanf_s("%d", &n); + } + srand(time(nullptr)); printf("first array\n"); printf("\n"); int *a; - a = new int[8]; - for (int i = 0; i < 8; i++) + a = new int[n]; + for (int i = 0; i < n; i++) a[i] = rand() % 20 - 10; - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) printf("%d ", a[i]); printf("\n"); - merge(a, 8); + merge(a, n); printf("array sorted with static lib\n"); - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) printf("%d ", a[i]); printf("\n"); printf("\n"); printf("second array\n"); printf("\n"); - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) a[i] = rand() % 20 - 10; - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) printf("%d ", a[i]); printf("\n"); @@ -36,30 +42,28 @@ int main() load = LoadLibrary("DynamicLib"); if (load != nullptr) { - Dllfunc = (DLLFUNC)GetProcAddress(load, "mergeD"); + Dllfunc = (DLLFUNC)GetProcAddress(load, "MergeD"); if (Dllfunc != nullptr) { - Dllfunc(a, 8); + Dllfunc(a, n); } FreeLibrary(load); } printf("array sorted with explicit dynamic lib\n"); - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) printf("%d ", a[i]); printf("\n"); printf("\n"); printf("third array\n"); printf("\n"); - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) a[i] = rand() % 20 - 10; - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) printf("%d ", a[i]); printf("\n"); - - mergeD(a, 8); - + MergeD(a, n); printf("array sorted with implicit dynamic lib\n"); - for (int i = 0; i < 8; i++) + for (int i = 0; i < n; i++) printf("%d ", a[i]); printf("\n"); delete[] a; diff --git a/StaticMath/DynamicLib/DynMerg.cpp b/StaticMath/DynamicLib/DynMerg.cpp index 4201971..5fd581e 100644 --- a/StaticMath/DynamicLib/DynMerg.cpp +++ b/StaticMath/DynamicLib/DynMerg.cpp @@ -1,50 +1,25 @@ - +#include "DynMerg.h" #include #include -extern "C" __declspec(dllexport) void mergeD(int* a, int n) +#include +using namespace std; +void MergeD(int* A, int fsize) { - int mid = n / 2; - if (n % 2 == 1) - mid++; - int h = 1; - - int* c = (int*)malloc(n * sizeof(int)); - int step; - while (h < n) - { - step = h; - int i = 0; - int j = mid; - int k = 0; - while (step <= mid) - { - while ((i < step) && (j < n) && (j < (mid + step))) - { - if (a[i] < a[j]) - { - c[k] = a[i]; - i++; k++; - } - else { - c[k] = a[j]; - j++; k++; - } - } - while (i < step) - { - c[k] = a[i]; - i++; k++; - } - while ((j < (mid + step)) && (j < n)) - { - c[k] = a[j]; - j++; k++; - } - step = step + h; - } - h = h * 2; - - for (i = 0; i < n; i++) - a[i] = c[i]; - } -} \ No newline at end of file + if (fsize < 2)return; + MergeD(A, fsize / 2); + MergeD(&A[fsize / 2], fsize - (fsize / 2)); + int* buf = new int[fsize]; + int idbuf = 0, idl = 0, idr = fsize / 2; + while ((idl < fsize / 2) && (idr < fsize)) + { + if (A[idl] < A[idr]) + buf[idbuf++] = A[idl++]; + else + buf[idbuf++] = A[idr++]; + } + while (idl < fsize / 2) buf[idbuf++] = A[idl++]; + while (idr < fsize) buf[idbuf++] = A[idr++]; + for (idl = 0; idl < fsize; idl++) + A[idl] = buf[idl]; + delete[]buf; +}; diff --git a/StaticMath/DynamicLib/DynMerg.h b/StaticMath/DynamicLib/DynMerg.h index 2bbe0a1..8fc13f8 100644 --- a/StaticMath/DynamicLib/DynMerg.h +++ b/StaticMath/DynamicLib/DynMerg.h @@ -1,7 +1,7 @@ #pragma once -#ifdef SORTDYNAMIC_EXPORT -#define SORTDYNAMIC_API __declspec(dllexport) +#ifdef DYNAMICLIB_EXPORT +#define DYNAMICLIB_API __declspec(dllexport) #else -#define SORTDYNAMIC_API __declspec(dllimport) +#define DYNAMICLIB_API __declspec(dllimport) #endif -extern "C" __declspec(dllexport) void mergeD(int* , int ); +extern "C" __declspec(dllexport) void MergeD(int* , int ); diff --git a/StaticMath/DynamicLib/DynamicLib.vcxproj b/StaticMath/DynamicLib/DynamicLib.vcxproj index 7041cd4..42be368 100644 --- a/StaticMath/DynamicLib/DynamicLib.vcxproj +++ b/StaticMath/DynamicLib/DynamicLib.vcxproj @@ -74,7 +74,7 @@ Level3 true - SORTDYNAMIC_EXPORT + DYNAMICLIB_EXPORT true @@ -88,7 +88,7 @@ true true true - SORTDYNAMIC_EXPORT + DYNAMICLIB_EXPORT true @@ -102,7 +102,7 @@ Level3 true - SORTDYNAMIC_EXPORT + DYNAMICLIB_EXPORT true @@ -116,7 +116,7 @@ true true true - SORTDYNAMIC_EXPORT + DYNAMICLIB_EXPORT true diff --git a/StaticMath/MathLibrary/MathLibrary.cpp b/StaticMath/MathLibrary/MathLibrary.cpp index e428d33..539156d 100644 --- a/StaticMath/MathLibrary/MathLibrary.cpp +++ b/StaticMath/MathLibrary/MathLibrary.cpp @@ -4,49 +4,23 @@ #include #include -void merge(int* a, int n) +void merge(int* A, int fsize) { - int mid = n / 2; - if (n % 2 == 1) - mid++; - int h = 1; - int* c = (int*)malloc(n * sizeof(int)); - int step; - while (h < n) - { - step = h; - int i = 0; - int j = mid; - int k = 0; - while (step <= mid) - { - while ((i < step) && (j < n) && (j < (mid + step))) - { - if (a[i] < a[j]) - { - c[k] = a[i]; - i++; k++; - } - else { - c[k] = a[j]; - j++; k++; - } - } - while (i < step) - { - c[k] = a[i]; - i++; k++; - } - while ((j < (mid + step)) && (j < n)) - { - c[k] = a[j]; - j++; k++; - } - step = step + h; - } - h = h * 2; - - for (i = 0; i < n; i++) - a[i] = c[i]; - } -} \ No newline at end of file + if (fsize < 2)return; + merge(A, fsize / 2); + merge(&A[fsize / 2], fsize - (fsize / 2)); + int* buf = new int[fsize]; + int idbuf = 0, idl = 0, idr = fsize / 2; + while ((idl < fsize / 2) && (idr < fsize)) + { + if (A[idl] < A[idr]) + buf[idbuf++] = A[idl++]; + else + buf[idbuf++] = A[idr++]; + } + while (idl < fsize / 2) buf[idbuf++] = A[idl++]; + while (idr < fsize) buf[idbuf++] = A[idr++]; + for (idl = 0; idl < fsize; idl++) + A[idl] = buf[idl]; + delete[]buf; +}; \ No newline at end of file diff --git a/StaticMath/MathLibrary/MathLibrary.h b/StaticMath/MathLibrary/MathLibrary.h index 3f1bcec..53ab7ce 100644 --- a/StaticMath/MathLibrary/MathLibrary.h +++ b/StaticMath/MathLibrary/MathLibrary.h @@ -1,4 +1,3 @@ #pragma once - void merge(int*, int); diff --git a/StaticMath/StaticMath.sln b/StaticMath/StaticMath.sln index 11da1b8..2d38b89 100644 --- a/StaticMath/StaticMath.sln +++ b/StaticMath/StaticMath.sln @@ -3,16 +3,10 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32929.385 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathLibrary", "MathLibrary\MathLibrary.vcxproj", "{30D05401-EEEE-45F0-8781-45DFFB51CF98}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathClient", "MathClient\MathClient.vcxproj", "{585DC573-7A02-431F-86C6-60DBE17C2539}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StaticLib", "MathLibrary\MathLibrary.vcxproj", "{30D05401-EEEE-45F0-8781-45DFFB51CF98}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicLib", "DynamicLib\DynamicLib.vcxproj", "{0343AEDF-2EFB-4D29-9571-C2C47C935C86}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathClient2", "ConsoleApplication1\ConsoleApplication1.vcxproj", "{E2D48B79-10F7-45FC-A2BC-FF453378C53D}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MathClient3", "MathClient3\MathClient3.vcxproj", "{28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}" -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AllLibs", "AllLibs\AllLibs.vcxproj", "{BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}" EndProject Global @@ -31,14 +25,6 @@ Global {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Release|x64.Build.0 = Release|x64 {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Release|x86.ActiveCfg = Release|Win32 {30D05401-EEEE-45F0-8781-45DFFB51CF98}.Release|x86.Build.0 = Release|Win32 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x64.ActiveCfg = Debug|x64 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x64.Build.0 = Debug|x64 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x86.ActiveCfg = Debug|Win32 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Debug|x86.Build.0 = Debug|Win32 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x64.ActiveCfg = Release|x64 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x64.Build.0 = Release|x64 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x86.ActiveCfg = Release|Win32 - {585DC573-7A02-431F-86C6-60DBE17C2539}.Release|x86.Build.0 = Release|Win32 {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Debug|x64.ActiveCfg = Debug|x64 {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Debug|x64.Build.0 = Debug|x64 {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Debug|x86.ActiveCfg = Debug|Win32 @@ -47,22 +33,6 @@ Global {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Release|x64.Build.0 = Release|x64 {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Release|x86.ActiveCfg = Release|Win32 {0343AEDF-2EFB-4D29-9571-C2C47C935C86}.Release|x86.Build.0 = Release|Win32 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x64.ActiveCfg = Debug|x64 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x64.Build.0 = Debug|x64 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x86.ActiveCfg = Debug|Win32 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Debug|x86.Build.0 = Debug|Win32 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x64.ActiveCfg = Release|x64 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x64.Build.0 = Release|x64 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x86.ActiveCfg = Release|Win32 - {E2D48B79-10F7-45FC-A2BC-FF453378C53D}.Release|x86.Build.0 = Release|Win32 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x64.ActiveCfg = Debug|x64 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x64.Build.0 = Debug|x64 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x86.ActiveCfg = Debug|Win32 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Debug|x86.Build.0 = Debug|Win32 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x64.ActiveCfg = Release|x64 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x64.Build.0 = Release|x64 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x86.ActiveCfg = Release|Win32 - {28F40427-D4A6-482E-A1B8-7A13FDE0E5A2}.Release|x86.Build.0 = Release|Win32 {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Debug|x64.ActiveCfg = Debug|x64 {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Debug|x64.Build.0 = Debug|x64 {BDBE7D2C-AC32-4C9F-988E-8A6E198FE848}.Debug|x86.ActiveCfg = Debug|Win32 -- GitLab From 24c006894e7c63a3e64c6973ed6b0f7816408f22 Mon Sep 17 00:00:00 2001 From: Zakhar Khomenkov Date: Thu, 16 Mar 2023 17:32:16 +0300 Subject: [PATCH 3/4] =?UTF-8?q?=D1=83=D0=B4=D0=B0=D0=BB=D0=B8=D0=BB=20?= =?UTF-8?q?=D1=84=D0=B0=D0=B9=D0=BB=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConsoleApplication1.vcxproj | 136 ---------------- .../ConsoleApplication1/MathClient2.cpp | 35 ----- StaticMath/MathClient/MathClient.cpp | 24 --- StaticMath/MathClient/MathClient.vcxproj | 144 ----------------- StaticMath/MathClient3/MathClient3.cpp | 24 --- StaticMath/MathClient3/MathClient3.vcxproj | 147 ------------------ 6 files changed, 510 deletions(-) delete mode 100644 StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj delete mode 100644 StaticMath/ConsoleApplication1/MathClient2.cpp delete mode 100644 StaticMath/MathClient/MathClient.cpp delete mode 100644 StaticMath/MathClient/MathClient.vcxproj delete mode 100644 StaticMath/MathClient3/MathClient3.cpp delete mode 100644 StaticMath/MathClient3/MathClient3.vcxproj diff --git a/StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj b/StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj deleted file mode 100644 index ce2c14f..0000000 --- a/StaticMath/ConsoleApplication1/ConsoleApplication1.vcxproj +++ /dev/null @@ -1,136 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {e2d48b79-10f7-45fc-a2bc-ff453378c53d} - ConsoleApplication1 - 10.0 - MathClient2 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - - - Console - true - true - true - - - - - - - - - \ No newline at end of file diff --git a/StaticMath/ConsoleApplication1/MathClient2.cpp b/StaticMath/ConsoleApplication1/MathClient2.cpp deleted file mode 100644 index ed5cfd9..0000000 --- a/StaticMath/ConsoleApplication1/MathClient2.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include -int main() -{ - srand(time(NULL)); - int* a; - a = new int[8]; - for (int i = 0; i < 8; i++) - a[i] = rand() % 20 - 10; - for (int i = 0; i < 8; i++) - printf("%d ", a[i]); - printf("\n"); - - - typedef int (CALLBACK* DLLFUNC) (int*, int); - HINSTANCE load; - DLLFUNC Dllfunc; - load = LoadLibrary(L"DynamicLib.dll"); - if (load != nullptr) - { - Dllfunc = (DLLFUNC)GetProcAddress(load, "mergeD"); - if (Dllfunc != nullptr) - { - Dllfunc(a, 8); - } - FreeLibrary(load); - } - printf("array sorted with explicit dynamic lib\n"); - for (int i = 0; i < 8; i++) - printf("%d ", a[i]); - printf("\n"); - delete[]a; - return 0; -} diff --git a/StaticMath/MathClient/MathClient.cpp b/StaticMath/MathClient/MathClient.cpp deleted file mode 100644 index 3cf56cd..0000000 --- a/StaticMath/MathClient/MathClient.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -#include -#include -#include "MathLibrary.h" - -int main() -{ - srand(time(NULL)); - int* a; - a = new int[8]; - for (int i = 0; i < 8; i++) - a[i] = rand() % 20 - 10; - - for (int i = 0; i < 8; i++) - printf("%d ", a[i]); - printf("\n"); - merge(a, 8); - printf("static\n"); - for (int i = 0; i < 8; i++) - printf("%d ", a[i]); - printf("\n"); - delete[] a; - return 0; -} \ No newline at end of file diff --git a/StaticMath/MathClient/MathClient.vcxproj b/StaticMath/MathClient/MathClient.vcxproj deleted file mode 100644 index b95e2cd..0000000 --- a/StaticMath/MathClient/MathClient.vcxproj +++ /dev/null @@ -1,144 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {585dc573-7a02-431f-86c6-60dbe17c2539} - MathClient - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) - - - Console - true - - - - - Level3 - true - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) - - - Console - true - true - true - - - - - Level3 - true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) - - - Console - true - - - - - Level3 - true - true - true - NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - true - C:\Users\user\source\repos\StaticMath\MathLibrary;%(AdditionalIncludeDirectories) - - - Console - true - true - true - - - - - - - - {30d05401-eeee-45f0-8781-45dffb51cf98} - - - - - - \ No newline at end of file diff --git a/StaticMath/MathClient3/MathClient3.cpp b/StaticMath/MathClient3/MathClient3.cpp deleted file mode 100644 index 60b04a3..0000000 --- a/StaticMath/MathClient3/MathClient3.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include -#include -#include -#include "DynMerg.h" -int main() -{ - srand(time(NULL)); - int* a; - a = new int[8]; - for (int i = 0; i < 8; i++) - a[i] = rand() % 20 - 10; - for (int i = 0; i < 8; i++) - printf("%d ", a[i]); - printf("\n"); - - mergeD(a, 8); - - printf("array sorted with implicit dynamic lib\n"); - for (int i = 0; i < 8; i++) - printf("%d ", a[i]); - printf("\n"); - delete[]a; - return 0; -} diff --git a/StaticMath/MathClient3/MathClient3.vcxproj b/StaticMath/MathClient3/MathClient3.vcxproj deleted file mode 100644 index ef5652d..0000000 --- a/StaticMath/MathClient3/MathClient3.vcxproj +++ /dev/null @@ -1,147 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 16.0 - Win32Proj - {28f40427-d4a6-482e-a1b8-7a13fde0e5a2} - MathClient3 - 10.0 - - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - Application - true - v143 - Unicode - - - Application - false - v143 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - SORTDYNAMIC_EXPORT - true - C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) - - - Console - true - DynamicLib.lib;%(AdditionalDependencies) - ..\$(IntDir);%(AdditionalLibraryDirectories) - - - - - Level3 - true - true - true - SORTDYNAMIC_EXPORT - true - C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) - - - Console - true - true - true - DynamicLib.lib;%(AdditionalDependencies) - ..\$(IntDir);%(AdditionalLibraryDirectories) - - - - - Level3 - true - SORTDYNAMIC_EXPORT - true - C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) - - - Console - true - DynamicLib.lib;%(AdditionalDependencies) - ..\$(IntDir);%(AdditionalLibraryDirectories) - - - - - Level3 - true - true - true - SORTDYNAMIC_EXPORT - true - C:\Users\user\source\repos\StaticMath\DynamicLib;%(AdditionalIncludeDirectories) - - - Console - true - true - true - DynamicLib.lib;%(AdditionalDependencies) - ..\$(IntDir);%(AdditionalLibraryDirectories) - - - - - - - - - \ No newline at end of file -- GitLab From 0bbbe0c90fc419db2707fb76825c143c61c702a5 Mon Sep 17 00:00:00 2001 From: Zakhar Khomenkov Date: Mon, 20 Mar 2023 18:17:57 +0300 Subject: [PATCH 4/4] =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StaticMath/AllLibs/AllLibs.cpp | 3 +-- StaticMath/DynamicLib/DynMerg.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/StaticMath/AllLibs/AllLibs.cpp b/StaticMath/AllLibs/AllLibs.cpp index 8b02932..4107d37 100644 --- a/StaticMath/AllLibs/AllLibs.cpp +++ b/StaticMath/AllLibs/AllLibs.cpp @@ -15,8 +15,7 @@ int main() srand(time(nullptr)); printf("first array\n"); printf("\n"); - int *a; - a = new int[n]; + int *a = new int[n]; for (int i = 0; i < n; i++) a[i] = rand() % 20 - 10; for (int i = 0; i < n; i++) diff --git a/StaticMath/DynamicLib/DynMerg.h b/StaticMath/DynamicLib/DynMerg.h index 8fc13f8..b647261 100644 --- a/StaticMath/DynamicLib/DynMerg.h +++ b/StaticMath/DynamicLib/DynMerg.h @@ -4,4 +4,4 @@ #else #define DYNAMICLIB_API __declspec(dllimport) #endif -extern "C" __declspec(dllexport) void MergeD(int* , int ); +extern "C" DYNAMICLIB_API void MergeD(int* , int ); -- GitLab