This commit is contained in:
bulat_inkin@mail.ru 2024-12-24 15:41:22 +04:00
parent a5b079ef34
commit 5c6beb7edc
4 changed files with 455 additions and 0 deletions

31
лаба 15.sln Normal file
View 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}") = "лаба 15", "лаба 15\лаба 15.vcxproj", "{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}"
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
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x64.ActiveCfg = Debug|x64
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x64.Build.0 = Debug|x64
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x86.ActiveCfg = Debug|Win32
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Debug|x86.Build.0 = Debug|Win32
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x64.ActiveCfg = Release|x64
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x64.Build.0 = Release|x64
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x86.ActiveCfg = Release|Win32
{7DB8AF7B-4BE0-4C8D-9CBD-A0ED7C7CE87B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {307B325D-0651-4005-9068-C50F6AA6EEB4}
EndGlobalSection
EndGlobal

267
лаба 15/FileName.cpp Normal file
View File

@ -0,0 +1,267 @@
#include <stdio.h>
#include <Windows.h>
#define MAX_N 8
#define MAX_M 10
int arr[MAX_N][MAX_M] = {
{ 0, 1, 222, 3},
{10, 11, 12, 13},
{20, 21, 22, 23}
};
int n = 3;
int m = 4;
void print() {
printf("!!!! print() !!!!\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
printf("%3d ", arr[i][j]);
}
printf("\n");
}
}
void print0() {
print();
}
void fillIx10() {
printf("!!!! fillIx10() !!!!\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = i * 10 + j;
}
}
}
void print1() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
fillIx10();
}
void fillZero() {
printf("!!!! fillZero() !!!!\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = 0;
}
}
}
void print2() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
fillZero();
}
void randFill0_9() {
printf("!!!! randFill() !!!!\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = rand() % 100;
}
}
}
void print3() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
randFill0_9();
}
void proizvedenie() {
printf("!!!! *10() !!!!\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (arr[i][j] % 2 != 0) {
arr[i][j] *= 10;
}
}
}
}
void print4() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
proizvedenie();
}
void delenie() {
printf("!!!! *10() !!!!\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
if (arr[i][j] % 10 == 0) {
arr[i][j] /= 10;
}
}
}
}
void print5() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
delenie();
}
int vvod() {
// Ââîä ýëåìåíòîâ ìàññèâà
printf("Ââåäèòå ýëåìåíòû ìàññèâà (%d x %d):\n", n, m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
printf("Ýëåìåíò [%d][%d]: \n", i, j);
scanf_s("%d", &arr[i][j]); // Ñ÷èòûâàíèå ýëåìåíòà
}
}
// Âûâîä ýëåìåíòîâ ìàññèâà
printf("Ââåäåííûé ìàññèâ:\n");
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
printf("%d ", arr[i][j]); // Âûâîä ýëåìåíòà
}
printf("\n");
}
return 0;
}
void deleteRow(int delRow) {
printf("!!!! deleteRow(%d) !!!!\n", delRow);
for (int i = delRow; i < n - 1; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = arr[i + 1][j];
}
}
n--;
}
void print7() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int num;
printf("Íîìåð ñòðîêè, êîòîðóþ íóæíî óäàëèòü: ");
scanf_s("%d", &num);
deleteRow(num);
}
void save() {
// Âûõîäíîé ôàéë
FILE* fout = NULL;
errno_t err = fopen_s(&fout, "C:\\Users\\home-PC\\Desktop\\ëàáû\\arr11.txt", "wt");
if (err != 0 || fout == NULL) {
printf("Âûõîäíîé ôàéë íå ñîçäàëñÿ\n");
return;
}
fprintf(fout, "%d ", n);
fprintf(fout, "%d\n", m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
fprintf(fout, "%d ", arr[i][j]);
}
fprintf(fout, "\n");
}
fclose(fout);
}
void load() {
FILE* fin = NULL;
errno_t err = fopen_s(&fin, "C:\\Users\\home-PC\\Desktop\\ëàáû\\arr11.txt", "rt");
if (err != 0 || fin == NULL) {
printf("Âõîäíîé ôàéë íå íàéäåí\n");
return;
}
fscanf_s(fin, "%d", &n);
fscanf_s(fin, "%d", &m);
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
fscanf_s(fin, "%d", &arr[i][j]);
}
}
fclose(fin);
}
void main() {
SetConsoleCP(1251);
SetConsoleOutputCP(1251);
int item;
do {
printf("\n");
print();
printf("------------------------------\n");
printf("Âûáåðèòå íóæíóþ âàì îïåðàöèþ:\n");
printf("1: çàïîëíèòü çíà÷åíèÿìè i*10+j \n");
printf("2: çàïîëíèòü íóëÿìè \n");
printf("3: çàïîëíèòü ñëó÷àéíûìè çíà÷åíèÿìè äî 100\n");
printf("4: âñå íå÷åòíûå óâåëè÷èòü â 10 ðàç\n");
printf("5: âñå êðàòíûå 10 óìåíüøèòü â 10 ðàç\n");
printf("6: ââîä ìàññèâà\n");
printf("7: óäàëèòü ñòðîêó\n");
printf("8: ñîõðàíèòü ìàññèâ â ôàéë\n");
printf("9: èçâëå÷ü ìàññèâ èç ôàéëà\n");
printf("\n");
printf("0: Âûéòè èç ïðîãðàììû\n");
printf("Âûáðàííàÿ îïåðàöèÿ >>>>>> ");
scanf_s("%d", &item);
switch (item) {
case 1:
print1();
break;
case 2:
print2();
break;
case 3:
print3();
break;
case 4:
print4();
break;
case 5:
print5();
break;
case 6:
vvod();
break;
case 7:
print7();
break;
case 8:
save();
break;
case 9:
load();
break;
}
} while (item != 0);
}

View 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>{7db8af7b-4be0-4c8d-9cbd-a0ed7c7ce87b}</ProjectGuid>
<RootNamespace>лаба15</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="FileName.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View 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="FileName.cpp">
<Filter>Файлы заголовков</Filter>
</ClCompile>
</ItemGroup>
</Project>