Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
f6d80b5d2f | |||
637d752ca0 | |||
3156127407 | |||
43a58dabf5 |
31
lab12/lab12.sln
Normal file
31
lab12/lab12.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35222.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab12", "lab12\lab12.vcxproj", "{45C15208-08C4-4B71-A4D6-B58EDC8DA968}"
|
||||
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
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Debug|x64.Build.0 = Debug|x64
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Debug|x86.Build.0 = Debug|Win32
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Release|x64.ActiveCfg = Release|x64
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Release|x64.Build.0 = Release|x64
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Release|x86.ActiveCfg = Release|Win32
|
||||
{45C15208-08C4-4B71-A4D6-B58EDC8DA968}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {14D2C521-5CAB-4F8D-ABBD-F284772C1B2C}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
30
lab12/lab12/Resource.h
Normal file
30
lab12/lab12/Resource.h
Normal file
@ -0,0 +1,30 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Включаемый файл, созданный в Microsoft Visual C++.
|
||||
// Используется lab12.rc
|
||||
|
||||
#define IDS_APP_TITLE 103
|
||||
|
||||
#define IDR_MAINFRAME 128
|
||||
#define IDD_LAB12_DIALOG 102
|
||||
#define IDD_ABOUTBOX 103
|
||||
#define IDM_ABOUT 104
|
||||
#define IDM_EXIT 105
|
||||
#define IDI_LAB12 107
|
||||
#define IDI_SMALL 108
|
||||
#define IDC_LAB12 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
lab12/lab12/framework.h
Normal file
15
lab12/lab12/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>
|
331
lab12/lab12/lab12.cpp
Normal file
331
lab12/lab12/lab12.cpp
Normal file
@ -0,0 +1,331 @@
|
||||
// lab12.cpp : Определяет точку входа для приложения.
|
||||
//
|
||||
|
||||
#include "framework.h"
|
||||
#include "lab12.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_LAB12, szWindowClass, MAX_LOADSTRING);
|
||||
MyRegisterClass(hInstance);
|
||||
|
||||
// Выполнить инициализацию приложения:
|
||||
if (!InitInstance (hInstance, nCmdShow))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_LAB12));
|
||||
|
||||
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_LAB12));
|
||||
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
|
||||
wcex.lpszMenuName = MAKEINTRESOURCEW(IDC_LAB12);
|
||||
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;
|
||||
}
|
||||
|
||||
void drawNet(HDC hdc, int width, int height, int step) {
|
||||
for (int i = 0; i <= width; i = i + step) {
|
||||
MoveToEx(hdc, i, 0, NULL);
|
||||
LineTo(hdc, i, height);
|
||||
}
|
||||
|
||||
for (int i = 0; i <= height; i = i + step) {
|
||||
MoveToEx(hdc, 0, i, NULL);
|
||||
LineTo(hdc, width, i);
|
||||
}
|
||||
}
|
||||
|
||||
void drawImage1(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 4, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[4] = {
|
||||
cx, cy - 20,
|
||||
cx + 20, cy + 20,
|
||||
cx - 20, cy + 20,
|
||||
cx, cy - 20
|
||||
};
|
||||
Polyline(hdc, p, 4);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawImage2(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 4, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[5] = {
|
||||
cx, cy - 20,
|
||||
cx + 20, cy,
|
||||
cx, cy + 20,
|
||||
cx - 20, cy,
|
||||
cx, cy - 20
|
||||
};
|
||||
Polyline(hdc, p, 5);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
void drawImage3(HDC hdc, int cx, int cy, COLORREF color) {
|
||||
HPEN hPen = CreatePen(PS_SOLID, 1, color);
|
||||
SelectObject(hdc, hPen);
|
||||
|
||||
POINT p[5] = {
|
||||
cx, cy,
|
||||
cx + 20, cy - 20,
|
||||
cx, cy + 20,
|
||||
cx - 20, cy - 20,
|
||||
cx, cy
|
||||
};
|
||||
Polyline(hdc, p, 5);
|
||||
|
||||
DeleteObject(hPen);
|
||||
}
|
||||
|
||||
struct Image {
|
||||
int x;
|
||||
int y;
|
||||
int vx;
|
||||
int vy;
|
||||
COLORREF color;
|
||||
};
|
||||
struct Image im1 = { 100, 100, 10, 10, RGB(200, 100, 128) };
|
||||
struct Image im2 = { 400, 100, -10, -10, RGB(100, 200, 128) };
|
||||
|
||||
#define IMG3NUM 8
|
||||
struct Image im3[IMG3NUM] = {
|
||||
{ 300, 100, 8, 10, RGB(150, 150, 220) },
|
||||
{ 300, 100, -4, 7, RGB(150, 150, 220) },
|
||||
{ 300, 100, -4, -11, RGB(150, 150, 220) },
|
||||
{ 300, 100, 3, 15, RGB(150, 150, 220) },
|
||||
{ 300, 100, 14, 7, RGB(150, 150, 220) },
|
||||
{ 300, 100, -10, 10, RGB(150, 150, 220) },
|
||||
{ 300, 100, 5, -10, RGB(150, 150, 220) },
|
||||
{ 300, 100, -10, -7, RGB(150, 150, 220) },
|
||||
};
|
||||
|
||||
void bounce(RECT rect, struct Image* pim) {
|
||||
if ((*pim).y >= rect.bottom and (*pim).vy > 0) {
|
||||
(*pim).vy = -(*pim).vy;
|
||||
(*pim).y = rect.bottom;
|
||||
}
|
||||
if ((*pim).y < rect.top + 1) {
|
||||
(*pim).vy = -(*pim).vy;
|
||||
(*pim).y = rect.top;
|
||||
}
|
||||
if ((*pim).x > rect.right - 1) {
|
||||
(*pim).vx = -(*pim).vx;
|
||||
(*pim).x = rect.right;
|
||||
}
|
||||
if ((*pim).x < rect.left + 1) {
|
||||
(*pim).vx = -(*pim).vx;
|
||||
(*pim).x = rect.left;
|
||||
}
|
||||
}
|
||||
|
||||
//void bounce(RECT rect, struct Image* pim) {
|
||||
// if ((*pim).y > rect.bottom - 1) {
|
||||
// (*pim).vy = -(*pim).vy;
|
||||
// (*pim).y = rect.bottom;
|
||||
// }
|
||||
// if ((*pim).y < rect.top + 1) {
|
||||
// (*pim).vy = -(*pim).vy;
|
||||
// (*pim).y = rect.top;
|
||||
// }
|
||||
// if ((*pim).x > rect.right - 1) {
|
||||
// (*pim).vx = -(*pim).vx;
|
||||
// (*pim).x = rect.right;
|
||||
// }
|
||||
// if ((*pim).x < rect.left + 1) {
|
||||
// (*pim).vx = -(*pim).vx;
|
||||
// (*pim).x = rect.left;
|
||||
// }
|
||||
//}
|
||||
|
||||
//
|
||||
// ФУНКЦИЯ: 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_CREATE:
|
||||
{
|
||||
SetTimer(hWnd, 1, 100, 0);
|
||||
}
|
||||
break;
|
||||
case WM_TIMER:
|
||||
{
|
||||
im1.x += im1.vx; im1.y += im1.vy;
|
||||
im2.x += im2.vx; im2.y += im2.vy;
|
||||
for (int i = 0; i < IMG3NUM; i++) {
|
||||
im3[i].x += im3[i].vx; im3[i].y += im3[i].vy;
|
||||
}
|
||||
InvalidateRect(hWnd, NULL, TRUE);
|
||||
}
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc = BeginPaint(hWnd, &ps);
|
||||
// TODO: Добавьте сюда любой код прорисовки, использующий HDC...
|
||||
|
||||
RECT rect;
|
||||
GetClientRect(hWnd, &rect);
|
||||
drawNet(hdc, rect.right, rect.bottom, 50);
|
||||
|
||||
bounce(rect, &im1);
|
||||
bounce(rect, &im2);
|
||||
for (int i = 0; i < IMG3NUM; i++) {
|
||||
bounce(rect, &im3[i]);
|
||||
}
|
||||
|
||||
drawImage1(hdc, im1.x, im1.y, im1.color);
|
||||
drawImage2(hdc, im2.x, im2.y, im2.color);
|
||||
for (int i = 0; i < IMG3NUM; i++) {
|
||||
drawImage3(hdc, im3[i].x, im3[i].y, im3[i].color);
|
||||
}
|
||||
|
||||
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
lab12/lab12/lab12.h
Normal file
3
lab12/lab12/lab12.h
Normal file
@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#include "resource.h"
|
BIN
lab12/lab12/lab12.ico
Normal file
BIN
lab12/lab12/lab12.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
BIN
lab12/lab12/lab12.rc
Normal file
BIN
lab12/lab12/lab12.rc
Normal file
Binary file not shown.
148
lab12/lab12/lab12.vcxproj
Normal file
148
lab12/lab12/lab12.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>{45c15208-08c4-4b71-a4d6-b58edc8da968}</ProjectGuid>
|
||||
<RootNamespace>lab12</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="lab12.h" />
|
||||
<ClInclude Include="Resource.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="lab12.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="lab12.rc" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="lab12.ico" />
|
||||
<Image Include="small.ico" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
49
lab12/lab12/lab12.vcxproj.filters
Normal file
49
lab12/lab12/lab12.vcxproj.filters
Normal file
@ -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="lab12.h">
|
||||
<Filter>Файлы заголовков</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="lab12.cpp">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="lab12.rc">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="small.ico">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
<Image Include="lab12.ico">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
BIN
lab12/lab12/small.ico
Normal file
BIN
lab12/lab12/small.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
6
lab12/lab12/targetver.h
Normal file
6
lab12/lab12/targetver.h
Normal file
@ -0,0 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
// // При включении SDKDDKVer.h будет задана самая новая из доступных платформ Windows.
|
||||
// Если вы планируете сборку приложения для предыдущей версии платформы Windows, включите WinSDKVer.h и
|
||||
// задайте желаемую платформу в макросе _WIN32_WINNT, прежде чем включать SDKDDKVer.h.
|
||||
#include <SDKDDKVer.h>
|
31
lab14/lab14.sln
Normal file
31
lab14/lab14.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35222.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab14", "lab14\lab14.vcxproj", "{976C8B3E-9653-472C-94F9-13C7C59A4371}"
|
||||
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
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Debug|x64.Build.0 = Debug|x64
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Debug|x86.Build.0 = Debug|Win32
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Release|x64.ActiveCfg = Release|x64
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Release|x64.Build.0 = Release|x64
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Release|x86.ActiveCfg = Release|Win32
|
||||
{976C8B3E-9653-472C-94F9-13C7C59A4371}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {A3E1F839-2D3D-4D5A-A443-E711427189C6}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
135
lab14/lab14/lab14.vcxproj
Normal file
135
lab14/lab14/lab14.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>{976c8b3e-9653-472c-94f9-13c7c59a4371}</ProjectGuid>
|
||||
<RootNamespace>lab14</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
lab14/lab14/lab14.vcxproj.filters
Normal file
22
lab14/lab14/lab14.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>
|
144
lab14/lab14/main.c
Normal file
144
lab14/lab14/main.c
Normal file
@ -0,0 +1,144 @@
|
||||
#include <stdio.h>
|
||||
#include <Windows.h>
|
||||
|
||||
|
||||
int index(int num, int arr[], int len) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
if (arr[i] == num) return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
int arrmax(int arr[], int len) {
|
||||
int max = arr[0];
|
||||
for (int i = 1; i < len; i++) {
|
||||
if (arr[i] > max) max = arr[i];
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
int arrmin(int arr[], int len) {
|
||||
int min = arr[0];
|
||||
for (int i = 1; i < len; i++) {
|
||||
if (arr[i] < min) min = arr[i];
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
void printarr(int arr[], int len) {
|
||||
printf("Ñîäåðæèìîå ìàññèâà: [");
|
||||
for (int i = 0; i < len; i++) {
|
||||
printf("%d, ", arr[i]);
|
||||
}
|
||||
printf("\b\b]\n");
|
||||
}
|
||||
|
||||
void deleteindex(int index, int arr[], int* len) {
|
||||
arr[index] = 0;
|
||||
for (int i = index; i < *len - 1; i++) {
|
||||
arr[i] = arr[i + 1];
|
||||
}
|
||||
*len -= 1;
|
||||
}
|
||||
|
||||
void insert(int num, int index, int arr[], int* len) {
|
||||
for (int i = *len; i > index; i--) {
|
||||
arr[i] = arr[i - 1];
|
||||
}
|
||||
*len += 1;
|
||||
arr[index] = num;
|
||||
}
|
||||
|
||||
#define ARRLEN 10
|
||||
|
||||
int main() {
|
||||
SetConsoleCP(1251);
|
||||
SetConsoleOutputCP(1251);
|
||||
|
||||
int arr[ARRLEN] = { 4, 7, 12, 3, 4, 8, -1, 6, 1, 7 };
|
||||
int size = 5;
|
||||
int id, val;
|
||||
/*for (int i = 0; i < ARRNUM; i++) {
|
||||
arr[i] = 0;
|
||||
}*/
|
||||
|
||||
int n = -1;
|
||||
do {
|
||||
puts("\n");
|
||||
printarr(arr, size);
|
||||
puts("Âûáåðèòå ïðîãðàììó");
|
||||
puts("1) Óäàëèòü ýëåìåíò ïî èíäåêñó");
|
||||
puts("2) Âñòàâèòü ýëåìåíò ïî èíäåêñó");
|
||||
puts("3) Óäàëèòü ìèíèìàëüíûé ýëåìåíò");
|
||||
puts("4) Ïåðåä ìèíèìàëüíûì ýëåìåíòîì âñòàâèòü 0");
|
||||
puts("5) Óäàëèòü âñå ÷¸òíûå ýëåìåíòû");
|
||||
puts("6) Äóáëèðîâàòü âñå ÷¸òíûå ýëåìåíòû");
|
||||
puts("7) ");
|
||||
puts("8) ");
|
||||
puts("9) ");
|
||||
puts("11) ");
|
||||
puts("");
|
||||
puts("0) exit program");
|
||||
|
||||
while (scanf_s(" %d", &n) != 1) {
|
||||
scanf_s("%*[^\n]");
|
||||
scanf_s("%*c");
|
||||
}
|
||||
puts("");
|
||||
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
printf("delete index = ");
|
||||
scanf_s("%d", &id);
|
||||
deleteindex(id, arr, &size);
|
||||
break;
|
||||
case 2:
|
||||
printf("value = ");
|
||||
scanf_s("%d", &val);
|
||||
printf("index = ");
|
||||
scanf_s("%d", &id);
|
||||
insert(val, id, arr, &size);
|
||||
break;
|
||||
case 3:
|
||||
deleteindex(index(arrmin(arr, size), arr, size), arr, &size);
|
||||
break;
|
||||
case 4:
|
||||
insert(0, index(arrmin(arr, size), arr, size), arr, &size);
|
||||
break;
|
||||
case 5:
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (arr[i] % 2 == 0) deleteindex(i, arr, &size);
|
||||
}
|
||||
break;
|
||||
case 6:
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (arr[i] % 2 == 0) {
|
||||
insert(arr[i], i, arr, &size);
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
|
||||
break;
|
||||
case 8:
|
||||
|
||||
break;
|
||||
case 9:
|
||||
|
||||
break;
|
||||
case 11:
|
||||
|
||||
break;
|
||||
case 0:
|
||||
puts("goodbye :3");
|
||||
break;
|
||||
default:
|
||||
puts("error: wrong N");
|
||||
break;
|
||||
}
|
||||
|
||||
} while (n != 0);
|
||||
return 0;
|
||||
}
|
31
lab9/lab9.sln
Normal file
31
lab9/lab9.sln
Normal file
@ -0,0 +1,31 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35222.181
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lab9", "lab9.vcxproj", "{C66F814A-1555-414A-96F3-876CB15A97E5}"
|
||||
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
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Debug|x64.Build.0 = Debug|x64
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Debug|x86.Build.0 = Debug|Win32
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Release|x64.ActiveCfg = Release|x64
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Release|x64.Build.0 = Release|x64
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Release|x86.ActiveCfg = Release|Win32
|
||||
{C66F814A-1555-414A-96F3-876CB15A97E5}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {00E25241-B7C1-4BDE-838D-4767E42EBF7D}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
139
lab9/lab9.vcxproj
Normal file
139
lab9/lab9.vcxproj
Normal file
@ -0,0 +1,139 @@
|
||||
<?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>{c66f814a-1555-414a-96f3-876cb15a97e5}</ProjectGuid>
|
||||
<RootNamespace>lab9</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>
|
||||
<ItemGroup>
|
||||
<Image Include="prime_of_n.png" />
|
||||
<Image Include="printNfacts.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
30
lab9/lab9.vcxproj.filters
Normal file
30
lab9/lab9.vcxproj.filters
Normal file
@ -0,0 +1,30 @@
|
||||
<?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>
|
||||
<ItemGroup>
|
||||
<Image Include="printNfacts.png">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
<Image Include="prime_of_n.png">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Image>
|
||||
</ItemGroup>
|
||||
</Project>
|
151
lab9/main.c
Normal file
151
lab9/main.c
Normal file
@ -0,0 +1,151 @@
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void print1_10() {
|
||||
int i = 1;
|
||||
do {
|
||||
printf("%d ", i);
|
||||
i++;
|
||||
} while (i <= 10);
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
void print10_1() {
|
||||
int i = 10;
|
||||
do {
|
||||
printf("%d ", i);
|
||||
i--;
|
||||
} while (i >= 0);
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
void print5odd() {
|
||||
int i = 1;
|
||||
int n = 1;
|
||||
do {
|
||||
printf("%d", n);
|
||||
n += 2;
|
||||
i++;
|
||||
} while (i <= 5);
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
void print100_10() {
|
||||
int n = 100;
|
||||
while (n >= 10) {
|
||||
printf_s("%d ", n);
|
||||
n = n - 10;
|
||||
}
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
void print1000_100() {
|
||||
int n = 1000;
|
||||
while (n >= 100) {
|
||||
printf_s("%d ", n);
|
||||
n = n - 100;
|
||||
}
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
void printNfacts(int n) {
|
||||
int a = 1;
|
||||
int count = 1;
|
||||
while (n >= count) {
|
||||
printf("%d ", a);
|
||||
count++;
|
||||
a = a * count;
|
||||
}
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
void fibonacci() {
|
||||
int n;
|
||||
printf("num of fibonacchi numbers = ");
|
||||
scanf_s("%d", &n);
|
||||
|
||||
long double a = 0.0;
|
||||
long double b = 1.0;
|
||||
long double c;
|
||||
n = n - 2;
|
||||
|
||||
if (n <= 0) {
|
||||
puts("wrong number");
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("0\n1\n");
|
||||
|
||||
do {
|
||||
c = a + b;
|
||||
a = b;
|
||||
b = c;
|
||||
printf("%.0Lf\n", c);
|
||||
n = n - 1;
|
||||
} while (n > 0);
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
void prime_of_n() {
|
||||
int n;
|
||||
printf("N = ");
|
||||
scanf_s("%d", &n);
|
||||
|
||||
int d = 2;
|
||||
while (n > 1) {
|
||||
if (n % d == 0) {
|
||||
printf("%d ", d);
|
||||
n = n / d;
|
||||
} else d++;
|
||||
}
|
||||
puts("\n");
|
||||
}
|
||||
|
||||
int main() {
|
||||
int n, num;
|
||||
do {
|
||||
puts("choose program");
|
||||
puts("1) print 1 -> 10");
|
||||
puts("2) print 10 -> 1");
|
||||
puts("3) print first five odd numbers");
|
||||
puts("11) print 100 90 ... 10");
|
||||
puts("12) print 1000 900 ... 100");
|
||||
puts("21) print first N factorials");
|
||||
puts("55) print fibonacci numbers");
|
||||
puts("4) prime factorization of N");
|
||||
puts("");
|
||||
puts("0) exit program");
|
||||
|
||||
scanf_s("%d", &n);
|
||||
puts("");
|
||||
switch (n)
|
||||
{
|
||||
case 1:
|
||||
print1_10();
|
||||
break;
|
||||
case 2:
|
||||
print10_1();
|
||||
break;
|
||||
case 3:
|
||||
print5odd();
|
||||
break;
|
||||
case 11:
|
||||
print100_10();
|
||||
break;
|
||||
case 12:
|
||||
print1000_100();
|
||||
break;
|
||||
case 21:
|
||||
printf("N = ");
|
||||
scanf_s("%d", &num);
|
||||
printNfacts(num);
|
||||
case 55:
|
||||
fibonacci();
|
||||
break;
|
||||
case 4:
|
||||
prime_of_n();
|
||||
}
|
||||
|
||||
} while (n != 0);
|
||||
return 0;
|
||||
}
|
BIN
lab9/prime_of_n.png
Normal file
BIN
lab9/prime_of_n.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 54 KiB |
BIN
lab9/printNfacts.png
Normal file
BIN
lab9/printNfacts.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 33 KiB |
Loading…
Reference in New Issue
Block a user