mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-18 08:39:11 +04:00
add lab23
This commit is contained in:
parent
4d01a02712
commit
ecd7646390
31
graphics plotter/graphics plotter.sln
Normal file
31
graphics plotter/graphics plotter.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35327.3
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "graphics plotter", "graphics plotter\graphics plotter.vcxproj", "{BE02616F-6955-47BA-83F8-60E3E922B39C}"
|
||||
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
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Debug|x64.Build.0 = Debug|x64
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Debug|x86.Build.0 = Debug|Win32
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Release|x64.ActiveCfg = Release|x64
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Release|x64.Build.0 = Release|x64
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Release|x86.ActiveCfg = Release|Win32
|
||||
{BE02616F-6955-47BA-83F8-60E3E922B39C}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A31C085B-40F3-474A-9774-E505AD526801}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
30
graphics plotter/graphics plotter/Resource.h
Normal file
30
graphics plotter/graphics plotter/Resource.h
Normal file
@ -0,0 +1,30 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Включаемый файл, созданный в Microsoft Visual C++.
|
||||
// Используется graphics plotter.rc
|
||||
|
||||
#define IDS_APP_TITLE 103
|
||||
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_GRAPHICSPLOTTER_DIALOG 102
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDI_GRAPHICSPLOTTER 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_GRAPHICSPLOTTER 109
|
||||
#define IDC_MYICON 2
|
||||
#ifndef IDC_STATIC
|
||||
#define IDC_STATIC -1
|
||||
#endif
|
||||
// Следующие стандартные значения для новых объектов
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
#define _APS_NO_MFC 130
|
||||
#define _APS_NEXT_RESOURCE_VALUE 129
|
||||
#define _APS_NEXT_COMMAND_VALUE 32771
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 110
|
||||
#endif
|
||||
#endif
|
15
graphics plotter/graphics plotter/framework.h
Normal file
15
graphics plotter/graphics plotter/framework.h
Normal file
@ -0,0 +1,15 @@
|
||||
// header.h: включаемый файл для стандартных системных включаемых файлов
|
||||
// или включаемые файлы для конкретного проекта
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "targetver.h"
|
||||
#define WIN32_LEAN_AND_MEAN // Исключите редко используемые компоненты из заголовков Windows
|
||||
// Файлы заголовков Windows
|
||||
#include <windows.h>
|
||||
// Файлы заголовков среды выполнения C
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
180
graphics plotter/graphics plotter/graphics plotter.cpp
Normal file
180
graphics plotter/graphics plotter/graphics plotter.cpp
Normal file
@ -0,0 +1,180 @@
|
||||
// graphics plotter.cpp : Определяет точку входа для приложения.
|
||||
//
|
||||
|
||||
#include "framework.h"
|
||||
#include "graphics plotter.h"
|
||||
|
||||
#define MAX_LOADSTRING 100
|
||||
|
||||
// Глобальные переменные:
|
||||
HINSTANCE hInst; // текущий экземпляр
|
||||
WCHAR szTitle[MAX_LOADSTRING]; // Текст строки заголовка
|
||||
WCHAR szWindowClass[MAX_LOADSTRING]; // имя класса главного окна
|
||||
|
||||
// Отправить объявления функций, включенных в этот модуль кода:
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||
BOOL InitInstance(HINSTANCE, int);
|
||||
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
||||
INT_PTR CALLBACK About(HWND, UINT, WPARAM, LPARAM);
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
// TODO: Разместите код здесь.
|
||||
|
||||
// Инициализация глобальных строк
|
||||
LoadStringW(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
|
||||
LoadStringW(hInstance, IDC_GRAPHICSPLOTTER, szWindowClass, MAX_LOADSTRING);
|
||||
MyRegisterClass(hInstance);
|
||||
|
||||
// Выполнить инициализацию приложения:
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_GRAPHICSPLOTTER));
|
||||
|
||||
MSG msg;
|
||||
|
||||
// Цикл основного сообщения:
|
||||
while (GetMessage(&msg, nullptr, 0, 0))
|
||||
{
|
||||
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
}
|
||||
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//
|
||||
// ФУНКЦИЯ: MyRegisterClass()
|
||||
//
|
||||
// ЦЕЛЬ: Регистрирует класс окна.
|
||||
//
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance)
|
||||
{
|
||||
WNDCLASSEXW wcex;
|
||||
|
||||
wcex.cbSize = sizeof(WNDCLASSEX);
|
||||
|
||||
wcex.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wcex.lpfnWndProc = WndProc;
|
||||
wcex.cbClsExtra = 0;
|
||||
wcex.cbWndExtra = 0;
|
||||
wcex.hInstance = hInstance;
|
||||
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_GRAPHICSPLOTTER));
|
||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_GRAPHICSPLOTTER);
|
||||
wcex.lpszClassName = szWindowClass;
|
||||
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));
|
||||
|
||||
return RegisterClassExW(&wcex);
|
||||
}
|
||||
|
||||
//
|
||||
// ФУНКЦИЯ: InitInstance(HINSTANCE, int)
|
||||
//
|
||||
// ЦЕЛЬ: Сохраняет маркер экземпляра и создает главное окно
|
||||
//
|
||||
// КОММЕНТАРИИ:
|
||||
//
|
||||
// В этой функции маркер экземпляра сохраняется в глобальной переменной, а также
|
||||
// создается и выводится главное окно программы.
|
||||
//
|
||||
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
{
|
||||
hInst = hInstance; // Сохранить маркер экземпляра в глобальной переменной
|
||||
|
||||
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
||||
CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr);
|
||||
|
||||
if (!hWnd)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//
|
||||
// ФУНКЦИЯ: WndProc(HWND, UINT, WPARAM, LPARAM)
|
||||
//
|
||||
// ЦЕЛЬ: Обрабатывает сообщения в главном окне.
|
||||
//
|
||||
// WM_COMMAND - обработать меню приложения
|
||||
// WM_PAINT - Отрисовка главного окна
|
||||
// WM_DESTROY - отправить сообщение о выходе и вернуться
|
||||
//
|
||||
//
|
||||
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
{
|
||||
int wmId = LOWORD(wParam);
|
||||
// Разобрать выбор в меню:
|
||||
switch (wmId)
|
||||
{
|
||||
case IDM_ABOUT:
|
||||
DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
|
||||
break;
|
||||
case IDM_EXIT:
|
||||
DestroyWindow(hWnd);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hWnd, &ps);
|
||||
// TODO: Добавьте сюда любой код прорисовки, использующий HDC...
|
||||
EndPaint(hWnd, &ps);
|
||||
}
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
break;
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Обработчик сообщений для окна "О программе".
|
||||
INT_PTR CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
UNREFERENCED_PARAMETER(lParam);
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return (INT_PTR)TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
||||
{
|
||||
EndDialog(hDlg, LOWORD(wParam));
|
||||
return (INT_PTR)TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return (INT_PTR)FALSE;
|
||||
}
|
3
graphics plotter/graphics plotter/graphics plotter.h
Normal file
3
graphics plotter/graphics plotter/graphics plotter.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
BIN
graphics plotter/graphics plotter/graphics plotter.ico
Normal file
BIN
graphics plotter/graphics plotter/graphics plotter.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
graphics plotter/graphics plotter/graphics plotter.rc
Normal file
BIN
graphics plotter/graphics plotter/graphics plotter.rc
Normal file
Binary file not shown.
148
graphics plotter/graphics plotter/graphics plotter.vcxproj
Normal file
148
graphics plotter/graphics plotter/graphics plotter.vcxproj
Normal file
@ -0,0 +1,148 @@
|
||||
<?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>{be02616f-6955-47ba-83f8-60e3e922b39c}</ProjectGuid>
|
||||
<RootNamespace>graphicsplotter</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</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;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<ConformanceMode>true</ConformanceMode>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="graphics plotter.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="graphics plotter.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="graphics plotter.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="graphics plotter.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -0,0 +1,49 @@
|
||||
<?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>
|
||||
<ClInclude Include="framework.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="targetver.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Resource.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="graphics plotter.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="graphics plotter.cpp">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="graphics plotter.rc">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="small.ico">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
<Image Include="graphics plotter.ico">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
BIN
graphics plotter/graphics plotter/small.ico
Normal file
BIN
graphics plotter/graphics plotter/small.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
6
graphics plotter/graphics plotter/targetver.h
Normal file
6
graphics plotter/graphics plotter/targetver.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows.
|
||||
// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и
|
||||
// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h.
|
||||
#include <SDKDDKVer.h>
|
@ -1,359 +1,361 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
void printarr(int arr[], int len) {
|
||||
printf("[");
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf("%d, ", arr[i]);
|
||||
}
|
||||
printf("\b\b]\n");
|
||||
}
|
||||
|
||||
int loadToFixedArray(int arr[], int len, char filename[]) {
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
puts("File not found");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int flen;
|
||||
fscanf_s(file, "%d", &flen);
|
||||
if (flen > len) {
|
||||
puts("Dataset if too big");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < flen; i++) {
|
||||
fscanf_s(file, "%d", &arr[i]);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
return flen;
|
||||
}
|
||||
|
||||
int load(int** parr, char filename[]) {
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
puts("File not found");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int len = 1;
|
||||
fscanf_s(file, "%d", &len);
|
||||
|
||||
*parr = (int*)malloc(sizeof(int) * len);
|
||||
if (*parr == NULL) {
|
||||
printf_s("Not enough memory to load data\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
fscanf_s(file, "%d", (*parr + i));
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void save(int arr[], int len, char filename[]) {
|
||||
FILE* file = fopen(filename, "w");
|
||||
if (file == NULL) {
|
||||
puts("Failed to create file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf_s(file, "%d\n", len);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
fprintf_s(file, "%d ", arr[i]);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void saveRandomArray() {
|
||||
int len = 1000;
|
||||
char filename[] = "rand.txt";
|
||||
|
||||
int* parr;
|
||||
parr = (int*)malloc(sizeof(int) * len);
|
||||
if (parr == NULL) {
|
||||
printf_s("Not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
parr[i] = rand() % 200 * 1000;
|
||||
}
|
||||
|
||||
save(parr, len, filename);
|
||||
|
||||
free(parr);
|
||||
}
|
||||
|
||||
void dotasks12(int arr[], int len) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sum += arr[i];
|
||||
}
|
||||
int average = sum / len;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (arr[i] > average) count++;
|
||||
}
|
||||
|
||||
int* parr;
|
||||
parr = (int*)malloc(sizeof(int) * (count + 1));
|
||||
if (parr == NULL) {
|
||||
printf_s("Not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (arr[i] > average) {
|
||||
parr[j] = arr[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
save(parr, count, "out12.txt");
|
||||
|
||||
free(parr);
|
||||
}
|
||||
|
||||
void task3() {
|
||||
int* arr;
|
||||
int len = load(&arr, "in3.txt");
|
||||
|
||||
int sum = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sum += arr[i];
|
||||
}
|
||||
double average = (double)sum / len;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if ((arr[i] > 0) && (arr[i] < average)) count++;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
puts("no temp that is > 0 and < average, exiting task3()");
|
||||
free(arr);
|
||||
return;
|
||||
}
|
||||
|
||||
int* parr;
|
||||
parr = (int*)malloc(sizeof(int) * (count + 2));
|
||||
if (parr == NULL) {
|
||||
printf_s("Not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if ((arr[i] > 0) && (arr[i] < average)) {
|
||||
parr[j] = arr[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
save(parr, count, "out3.txt");
|
||||
|
||||
free(arr);
|
||||
free(parr);
|
||||
}
|
||||
|
||||
void task4() {
|
||||
int* pdata;
|
||||
int len = load(&pdata, "in4.txt");
|
||||
|
||||
int max = pdata[0];
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] > max) max = pdata[i];
|
||||
}
|
||||
|
||||
int* pout = (int*)malloc(sizeof(int) * len);
|
||||
if (pout == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
double high = (double)max * 0.667;
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] >= high) {
|
||||
pout[count] = pdata[i];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
save(pout, count, "out4.txt");
|
||||
|
||||
free(pdata);
|
||||
free(pout);
|
||||
}
|
||||
|
||||
void swap(int* arr, int i, int j) {
|
||||
int temp = arr[i];
|
||||
arr[i] = arr[j];
|
||||
arr[j] = temp;
|
||||
}
|
||||
|
||||
void bubbleSort(int arr[], int n) {
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
|
||||
// Last i elements are already in place, so the loop
|
||||
// will only num n - i - 1 times
|
||||
for (int j = 0; j < n - i - 1; j++) {
|
||||
if (arr[j] > arr[j + 1])
|
||||
swap(arr, j, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void task5() {
|
||||
int* pdata;
|
||||
int len = load(&pdata, "in5.txt");
|
||||
|
||||
int oddCount = 0;
|
||||
int evenCount = 0;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] % 2 == 0) {
|
||||
evenCount++;
|
||||
}
|
||||
else {
|
||||
oddCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (oddCount == 0 || evenCount == 0) {
|
||||
puts("No odds or evens, exiting task5()");
|
||||
free(pdata);
|
||||
return;
|
||||
}
|
||||
|
||||
int* peven = (int*)malloc(sizeof(int) * (evenCount + 2));
|
||||
if (peven == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int* podd = (int*)malloc(sizeof(int) * (oddCount + 2));
|
||||
if (podd == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int ieven = 0, iodd = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] % 2 == 0) {
|
||||
peven[ieven] = pdata[i];
|
||||
ieven++;
|
||||
}
|
||||
else {
|
||||
podd[iodd] = pdata[i];
|
||||
iodd++;
|
||||
}
|
||||
}
|
||||
|
||||
bubbleSort(peven, evenCount);
|
||||
bubbleSort(podd, oddCount);
|
||||
|
||||
FILE* file = fopen("out5.txt", "w");
|
||||
if (file == NULL) {
|
||||
puts("Failed to create file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf_s(file, "%d\n", len);
|
||||
|
||||
for (int i = 0; i < evenCount; i++) {
|
||||
fprintf_s(file, "%d ", peven[i]);
|
||||
}
|
||||
|
||||
for (int i = oddCount - 1; i >= 0; i--) {
|
||||
fprintf_s(file, "%d ", podd[i]);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
free(pdata);
|
||||
free(peven);
|
||||
free(podd);
|
||||
}
|
||||
|
||||
int clip(int n, int lower, int upper) {
|
||||
return max(lower, min(n, upper));
|
||||
}
|
||||
|
||||
void createRandomBinFiles(int n, int size) {
|
||||
if (size <= 0) {
|
||||
puts("size can't be less than 1");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
unsigned char* pa = (int*)malloc(size);
|
||||
if (pa == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
pa[i] = (unsigned char)rand();
|
||||
}
|
||||
|
||||
char path[_MAX_PATH];
|
||||
sprintf_s(path, _MAX_PATH, "randbin\\bin%d", i);
|
||||
|
||||
FILE* file = fopen(path, "wb");
|
||||
if (file == NULL) {
|
||||
puts("Failed to create file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fwrite(pa, sizeof(unsigned char), size, file);
|
||||
|
||||
fclose(file);
|
||||
free(pa);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
srand((unsigned int)time(NULL));
|
||||
|
||||
clock_t start = clock();
|
||||
|
||||
//saveRandomArray();
|
||||
|
||||
// task 1
|
||||
/*int fixarr[1000];
|
||||
int flen = loadToFixedArray(fixarr, 1000, "in12.txt");
|
||||
dotasks12(fixarr, flen);*/
|
||||
|
||||
// task 2
|
||||
//int* parr;
|
||||
//int len = load(&parr, "in12.txt");
|
||||
//dotasks12(parr, len);
|
||||
//printarr(parr, len);
|
||||
//free(parr);
|
||||
//parr = NULL;
|
||||
|
||||
//task3();
|
||||
|
||||
//task4();
|
||||
|
||||
//task5();
|
||||
|
||||
createRandomBinFiles(32, 64 * 1024 * 1024);
|
||||
|
||||
printf_s("time = %.3lf seconds", (double)(clock() - start) / (double)CLOCKS_PER_SEC);
|
||||
|
||||
return 0;
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
void printarr(int arr[], int len) {
|
||||
printf("[");
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf("%d, ", arr[i]);
|
||||
}
|
||||
printf("\b\b]\n");
|
||||
}
|
||||
|
||||
int loadToFixedArray(int arr[], int len, char filename[]) {
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
puts("File not found");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int flen;
|
||||
fscanf_s(file, "%d", &flen);
|
||||
if (flen > len) {
|
||||
puts("Dataset if too big");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < flen; i++) {
|
||||
fscanf_s(file, "%d", &arr[i]);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
return flen;
|
||||
}
|
||||
|
||||
int load(int** parr, char filename[]) {
|
||||
FILE* file = fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
puts("File not found");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int len = 1;
|
||||
fscanf_s(file, "%d", &len);
|
||||
|
||||
*parr = (int*)malloc(sizeof(int) * len);
|
||||
if (*parr == NULL) {
|
||||
printf_s("Not enough memory to load data\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
fscanf_s(file, "%d", (*parr + i));
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
void save(int arr[], int len, char filename[]) {
|
||||
FILE* file = fopen(filename, "w");
|
||||
if (file == NULL) {
|
||||
puts("Failed to create file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf_s(file, "%d\n", len);
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
fprintf_s(file, "%d ", arr[i]);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void saveRandomArray() {
|
||||
int len = 1000;
|
||||
char filename[] = "rand.txt";
|
||||
|
||||
int* parr;
|
||||
parr = (int*)malloc(sizeof(int) * len);
|
||||
if (parr == NULL) {
|
||||
printf_s("Not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
parr[i] = rand() % 200 * 1000;
|
||||
}
|
||||
|
||||
save(parr, len, filename);
|
||||
|
||||
free(parr);
|
||||
}
|
||||
|
||||
void dotasks12(int arr[], int len) {
|
||||
int sum = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sum += arr[i];
|
||||
}
|
||||
int average = sum / len;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (arr[i] > average) count++;
|
||||
}
|
||||
|
||||
int* parr;
|
||||
parr = (int*)malloc(sizeof(int) * (count + 1));
|
||||
if (parr == NULL) {
|
||||
printf_s("Not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (arr[i] > average) {
|
||||
parr[j] = arr[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
save(parr, count, "out12.txt");
|
||||
|
||||
free(parr);
|
||||
}
|
||||
|
||||
void task3() {
|
||||
int* arr;
|
||||
int len = load(&arr, "in3.txt");
|
||||
|
||||
int sum = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sum += arr[i];
|
||||
}
|
||||
double average = (double)sum / len;
|
||||
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if ((arr[i] > 0) && (arr[i] < average)) count++;
|
||||
}
|
||||
|
||||
if (count == 0) {
|
||||
puts("no temp that is > 0 and < average, exiting task3()");
|
||||
free(arr);
|
||||
return;
|
||||
}
|
||||
|
||||
int* parr;
|
||||
parr = (int*)malloc(sizeof(int) * (count + 2));
|
||||
if (parr == NULL) {
|
||||
printf_s("Not enough memory\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if ((arr[i] > 0) && (arr[i] < average)) {
|
||||
parr[j] = arr[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
save(parr, count, "out3.txt");
|
||||
|
||||
free(arr);
|
||||
free(parr);
|
||||
}
|
||||
|
||||
void task4() {
|
||||
int* pdata;
|
||||
int len = load(&pdata, "in4.txt");
|
||||
|
||||
int max = pdata[0];
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] > max) max = pdata[i];
|
||||
}
|
||||
|
||||
int* pout = (int*)malloc(sizeof(int) * len);
|
||||
if (pout == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
double high = (double)max * 0.667;
|
||||
int count = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] >= high) {
|
||||
pout[count] = pdata[i];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
save(pout, count, "out4.txt");
|
||||
|
||||
free(pdata);
|
||||
free(pout);
|
||||
}
|
||||
|
||||
void swap(int* arr, int i, int j) {
|
||||
int temp = arr[i];
|
||||
arr[i] = arr[j];
|
||||
arr[j] = temp;
|
||||
}
|
||||
|
||||
void bubbleSort(int arr[], int n) {
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
|
||||
// Last i elements are already in place, so the loop
|
||||
// will only num n - i - 1 times
|
||||
for (int j = 0; j < n - i - 1; j++) {
|
||||
if (arr[j] > arr[j + 1])
|
||||
swap(arr, j, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void task5() {
|
||||
int* pdata;
|
||||
int len = load(&pdata, "in5.txt");
|
||||
|
||||
int oddCount = 0;
|
||||
int evenCount = 0;
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] % 2 == 0) {
|
||||
evenCount++;
|
||||
}
|
||||
else {
|
||||
oddCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (oddCount == 0 || evenCount == 0) {
|
||||
puts("No odds or evens, exiting task5()");
|
||||
free(pdata);
|
||||
return;
|
||||
}
|
||||
|
||||
int* peven = (int*)malloc(sizeof(int) * (evenCount + 2));
|
||||
if (peven == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int* podd = (int*)malloc(sizeof(int) * (oddCount + 2));
|
||||
if (podd == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
int ieven = 0, iodd = 0;
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (pdata[i] % 2 == 0) {
|
||||
peven[ieven] = pdata[i];
|
||||
ieven++;
|
||||
}
|
||||
else {
|
||||
podd[iodd] = pdata[i];
|
||||
iodd++;
|
||||
}
|
||||
}
|
||||
|
||||
bubbleSort(peven, evenCount);
|
||||
bubbleSort(podd, oddCount);
|
||||
|
||||
FILE* file = fopen("out5.txt", "w");
|
||||
if (file == NULL) {
|
||||
puts("Failed to create file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fprintf_s(file, "%d\n", len);
|
||||
|
||||
for (int i = 0; i < evenCount; i++) {
|
||||
fprintf_s(file, "%d ", peven[i]);
|
||||
}
|
||||
|
||||
for (int i = oddCount - 1; i >= 0; i--) {
|
||||
fprintf_s(file, "%d ", podd[i]);
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
|
||||
free(pdata);
|
||||
free(peven);
|
||||
free(podd);
|
||||
}
|
||||
|
||||
int clip(int n, int lower, int upper) {
|
||||
return max(lower, min(n, upper));
|
||||
}
|
||||
|
||||
void createRandomBinFiles(int n, int size) {
|
||||
if (size <= 0) {
|
||||
puts("size can't be less than 1");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
unsigned char* pa = malloc(size);
|
||||
if (pa == NULL) {
|
||||
puts("Out of memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (i % 256 == 0) {
|
||||
srand((unsigned int)(clock() * time(NULL)));
|
||||
}
|
||||
pa[i] = (unsigned char)rand();
|
||||
}
|
||||
|
||||
char path[_MAX_PATH];
|
||||
sprintf_s(path, _MAX_PATH, "randbin\\bin%d", i);
|
||||
|
||||
FILE* file = fopen(path, "wb");
|
||||
if (file == NULL) {
|
||||
puts("Failed to create file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
fwrite(pa, sizeof(unsigned char), size, file);
|
||||
|
||||
fclose(file);
|
||||
free(pa);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
clock_t start = clock();
|
||||
|
||||
//saveRandomArray();
|
||||
|
||||
// task 1
|
||||
/*int fixarr[1000];
|
||||
int flen = loadToFixedArray(fixarr, 1000, "in12.txt");
|
||||
dotasks12(fixarr, flen);*/
|
||||
|
||||
// task 2
|
||||
//int* parr;
|
||||
//int len = load(&parr, "in12.txt");
|
||||
//dotasks12(parr, len);
|
||||
//printarr(parr, len);
|
||||
//free(parr);
|
||||
//parr = NULL;
|
||||
|
||||
//task3();
|
||||
|
||||
//task4();
|
||||
|
||||
//task5();
|
||||
|
||||
createRandomBinFiles(128, 64 * 1024 * 1024);
|
||||
|
||||
printf_s("time = %.3lf seconds", (double)(clock() - start) / (double)CLOCKS_PER_SEC);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1 +0,0 @@
|
||||
hfhxdffhtdx
|
7
lab23/files/text1.txt
Normal file
7
lab23/files/text1.txt
Normal file
@ -0,0 +1,7 @@
|
||||
wkfkaio gkesgsook pgkdeopgo
|
||||
drgkoigks
|
||||
qbgkopdse edsobhkoidse
|
||||
|
||||
|
||||
|
||||
|
31
lab23/lab23.sln
Normal file
31
lab23/lab23.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35327.3
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab23", "lab23.vcxproj", "{F21B9CEC-77E1-4118-A843-6670EFA401E3}"
|
||||
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
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Debug|x64.Build.0 = Debug|x64
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Debug|x86.Build.0 = Debug|Win32
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Release|x64.ActiveCfg = Release|x64
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Release|x64.Build.0 = Release|x64
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Release|x86.ActiveCfg = Release|Win32
|
||||
{F21B9CEC-77E1-4118-A843-6670EFA401E3}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {4AFFEBF9-BBBB-4B68-B500-E2E849A8AB39}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
135
lab23/lab23.vcxproj
Normal file
135
lab23/lab23.vcxproj
Normal file
@ -0,0 +1,135 @@
|
||||
<?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>{f21b9cec-77e1-4118-a843-6670efa401e3}</ProjectGuid>
|
||||
<RootNamespace>lab23</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="main.c" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
22
lab23/lab23.vcxproj.filters
Normal file
22
lab23/lab23.vcxproj.filters
Normal file
@ -0,0 +1,22 @@
|
||||
<?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="main.c">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
26
lab23/main.c
Normal file
26
lab23/main.c
Normal file
@ -0,0 +1,26 @@
|
||||
#include <stdio.h>
|
||||
#define BUF_LEN 128
|
||||
|
||||
void task1() {
|
||||
char filepath[] = "files/text1.txt";
|
||||
FILE* fin = fopen(filepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
31
lab24/lab24.sln
Normal file
31
lab24/lab24.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35327.3
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab24", "lab24.vcxproj", "{261B6E46-77EA-4D5C-96EF-81D1AF276697}"
|
||||
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
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Debug|x64.Build.0 = Debug|x64
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Debug|x86.Build.0 = Debug|Win32
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Release|x64.ActiveCfg = Release|x64
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Release|x64.Build.0 = Release|x64
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Release|x86.ActiveCfg = Release|Win32
|
||||
{261B6E46-77EA-4D5C-96EF-81D1AF276697}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {3617BE18-4691-44D5-8DC3-55EBB9D9F1C2}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
BIN
Лекции/FIST2024_OsnProgram_lek_12_Textovye_fayly_HTML.pptx
Normal file
BIN
Лекции/FIST2024_OsnProgram_lek_12_Textovye_fayly_HTML.pptx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user