commit1
This commit is contained in:
parent
1256ce7bd4
commit
0a40f356b4
137
Lab9-10_OAandP/Lab9-10_OAandP.cpp
Normal file
137
Lab9-10_OAandP/Lab9-10_OAandP.cpp
Normal file
@ -0,0 +1,137 @@
|
||||
#include <Windows.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void print1_10(), print10_1(), print5Odds(), print100_10_while(), print1000_100_while(), print1000_0_while(), Task1(), Task2();
|
||||
|
||||
void main() {
|
||||
SetConsoleCP(1251);
|
||||
SetConsoleOutputCP(1251);
|
||||
int n;
|
||||
do {
|
||||
printf("\n");
|
||||
printf("\n");
|
||||
printf("Выберите нужную вам операцию:\n");
|
||||
printf("1: Вывести числа от 1 до 10\n");
|
||||
printf("2: Вывести числа от 10 до 1\n");
|
||||
printf("3: Вывести 5 первых нечетных чисел начиная с 1\n");
|
||||
printf("11: Вывести числа от 100 до 10 с шагом 10\n");
|
||||
printf("12: Вывести числа от 1000 до 100 с шагом 100\n");
|
||||
printf("20: Вывести числа от 1000 до 0 с шагом 16\n");
|
||||
printf("101: 10 ЛАБА - Задача 1\n");
|
||||
printf("102: 10 ЛАБА - Задача 2\n");
|
||||
printf("\n");
|
||||
printf("0: Выйти из программы\n");
|
||||
scanf_s("%d", &n);
|
||||
switch (n) {
|
||||
case 1:
|
||||
print1_10();
|
||||
break;
|
||||
case 2:
|
||||
print10_1();
|
||||
break;
|
||||
case 3:
|
||||
print5Odds();
|
||||
break;
|
||||
case 11:
|
||||
print100_10_while();
|
||||
break;
|
||||
case 12:
|
||||
print1000_100_while();
|
||||
break;
|
||||
case 20:
|
||||
print1000_0_while();
|
||||
break;
|
||||
case 101:
|
||||
Task1();
|
||||
break;
|
||||
case 102:
|
||||
Task2();
|
||||
break;
|
||||
}
|
||||
} while (n != 0);
|
||||
}
|
||||
|
||||
void print1_10() {
|
||||
int a = 1;
|
||||
do {
|
||||
printf("%d ", a);
|
||||
a++;
|
||||
} while (a <= 10);
|
||||
}
|
||||
void print10_1() {
|
||||
int a = 10;
|
||||
while (a >= 1) {
|
||||
printf("%d ", a);
|
||||
a--;
|
||||
}
|
||||
}
|
||||
void print5Odds() {
|
||||
int a = 1;
|
||||
int i = 1;
|
||||
while (i <= 5) {
|
||||
printf("%d ", a);
|
||||
a = a + 2;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
void print100_10_while() {
|
||||
int a = 100;
|
||||
while (a >= 10) {
|
||||
printf("%d ", a);
|
||||
a = a - 10;
|
||||
}
|
||||
}
|
||||
void print1000_100_while() {
|
||||
int a = 1000;
|
||||
while (a >= 100) {
|
||||
printf("%d ", a);
|
||||
a = a - 100;
|
||||
}
|
||||
}
|
||||
void print1000_0_while() {
|
||||
int a = 1000;
|
||||
while (a >= 0) {
|
||||
printf("%d ", a);
|
||||
a = a - 16;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Task1() {
|
||||
int n, m;
|
||||
printf("Введите кол-во строк : ");
|
||||
scanf_s("%d", &n);
|
||||
printf("Введите кол-во столбцов : ");
|
||||
scanf_s("%d", &m);
|
||||
int i = 1;
|
||||
do {
|
||||
int j = 1;
|
||||
do {
|
||||
int ij = i * 10 + j;
|
||||
printf("%d ", ij);
|
||||
j++;
|
||||
} while (j <= m);
|
||||
printf("\n");
|
||||
i++;
|
||||
} while (i <= n);
|
||||
}
|
||||
void Task2() {
|
||||
int i = 1;
|
||||
do {
|
||||
int j = 1;
|
||||
do {
|
||||
int ij = i * j;
|
||||
printf("%3d ", ij);
|
||||
j++;
|
||||
} while (j <= 10);
|
||||
printf("\n");
|
||||
i++;
|
||||
} while (i <= 10);
|
||||
}
|
37
Lab9-10_OAandP/Lab9-10_OAandP.sln
Normal file
37
Lab9-10_OAandP/Lab9-10_OAandP.sln
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.11.35312.102
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lab9-10_OAandP", "Lab9-10_OAandP.vcxproj", "{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x64.Build.0 = Debug|x64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x86.ActiveCfg = Debug|Win32
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Debug|x86.Build.0 = Debug|Win32
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x64.ActiveCfg = Release|x64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x64.Build.0 = Release|x64
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x86.ActiveCfg = Release|Win32
|
||||
{DA530082-7B6B-4BA5-97BF-4F8149FBC0D5}.Release|x86.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {98EF6571-C30A-4B47-8668-A449C51939AD}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
190
Lab9-10_OAandP/Lab9-10_OAandP.vcxproj
Normal file
190
Lab9-10_OAandP/Lab9-10_OAandP.vcxproj
Normal file
@ -0,0 +1,190 @@
|
||||
<?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>
|
||||
<ProjectConfiguration Include="Debug|ARM64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|ARM64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>ARM64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<VCProjectVersion>17.0</VCProjectVersion>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<ProjectGuid>{da530082-7b6b-4ba5-97bf-4f8149fbc0d5}</ProjectGuid>
|
||||
<RootNamespace>Lab910OAandP</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>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v143</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" 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>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<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|ARM64'">
|
||||
<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>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
|
||||
<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|ARM64'">
|
||||
<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="..\..\..\..\..\Mac\Home\Desktop\lab13\lab13\main.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
22
Lab9-10_OAandP/Lab9-10_OAandP.vcxproj.filters
Normal file
22
Lab9-10_OAandP/Lab9-10_OAandP.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="..\..\..\..\..\Mac\Home\Desktop\lab13\lab13\main.cpp">
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
269
Lab9-10_OAandP/main.cpp
Normal file
269
Lab9-10_OAandP/main.cpp
Normal file
@ -0,0 +1,269 @@
|
||||
#include <stdio.h>
|
||||
#include <Windows.h>
|
||||
|
||||
#define N_E 10
|
||||
int item;
|
||||
int arr[5];
|
||||
|
||||
void InputKey() {
|
||||
printf("Ââåäèòå 5 ÷èñåë ÷åðåç Enter \n");
|
||||
for (int i = 0; i < 5; i++) {
|
||||
printf("Ââåäèòå ñëåäóþùåå ÷èñëî \n");
|
||||
scanf_s("%d", &arr[i]);
|
||||
}
|
||||
for (int i1 = 0; i1 < 5; i1++) {
|
||||
printf("%d ", arr[i1]);
|
||||
}
|
||||
}
|
||||
|
||||
void x10() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
|
||||
if (arr[i] % 2 == 0) {
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
arr[i] *= 10;
|
||||
}
|
||||
}
|
||||
for (int i1 = 0; i1 < 5; i1++) {
|
||||
printf("%d ", arr[i1]);
|
||||
}
|
||||
}
|
||||
|
||||
int minNum() {
|
||||
int minNum1 = arr[0];
|
||||
int saveNum = 0;
|
||||
for (int i1 = 0; i1 < 5; i1++) {
|
||||
if (arr[i1] < minNum1) {
|
||||
minNum1 = arr[i1];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return minNum1;
|
||||
}
|
||||
|
||||
int count10() {
|
||||
int cnt = 0;
|
||||
for (int i1 = 0; i1 < 5; i1++) {
|
||||
if (arr[i1] > 10) {
|
||||
cnt++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
int x2ForLast() {
|
||||
int cnt;
|
||||
for (int i = 4; i >= 0; i--) {
|
||||
if (arr[i] % 2 == 0) {
|
||||
cnt = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
int findIndexMin() {
|
||||
int maxNum = 100000000;
|
||||
int index = 0;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (arr[i] < maxNum) {
|
||||
index = i;
|
||||
maxNum = arr[i];
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
void seven() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (arr[i] % 2 == 0) {
|
||||
arr[i] *= -1;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
}
|
||||
void eight() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (arr[i] < 4) {
|
||||
arr[i] = 4;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void nine() {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (arr[i] % 2 == 0) {
|
||||
arr[i] = 0;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < 5; i++) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void deleteElement(int ind) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (i != ind) {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void insertElement(int index, int value) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (index == i) {
|
||||
printf("%d ", value);
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
else {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
int minNum1() {
|
||||
int minNum1 = arr[0];
|
||||
int saveNum = 0;
|
||||
for (int i1 = 0; i1 < 5; i1++) {
|
||||
if (arr[i1] < minNum1) {
|
||||
minNum1 = arr[i1];
|
||||
saveNum = i1;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return saveNum;
|
||||
}
|
||||
|
||||
void LastTask() {
|
||||
bool flag = false;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (arr[i] % 2 == 0 and flag == false) {
|
||||
flag = true;
|
||||
continue;
|
||||
flag = true;
|
||||
}
|
||||
else {
|
||||
printf("%d ", arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
SetConsoleCP(1251);
|
||||
SetConsoleOutputCP(1251);
|
||||
do {
|
||||
printf("\nÂâåäèòå êîìàíäó\n");
|
||||
printf("1: Ââåñòè ñ êëàâèàòóðû ìàññèâ\n");
|
||||
printf("2: x10 äëÿ âñåõ íå÷åòíûõ ýëåìåíòîâ\n");
|
||||
printf("3: Íàéòè ìèíèìàëüíûé ýëåìåíò\n");
|
||||
printf("4: Ñêîëüêî ýëåìåíòîâ áîëüøå 10\n");
|
||||
printf("5: 2X Ïîñëåäíåå ÷åòíîå ÷èñëî\n");
|
||||
printf("6: Ñêîëüêî ÷åòíûõ ëåâåå ìèíèìàëüíîãî\n");
|
||||
printf("7: Âñå ÷åòíûå ýëåìåíòû ìàññèâà óìíîæèòü íà -1\n");
|
||||
printf("8: Âñå ýëåìåíòû ìàññèâà èìåþùèå çíà÷åíèÿ ìåíüøå 4 çàìåíèòü íà 4\n");
|
||||
printf("9: Îáíóëèòü ÷åòíûå\n"); //Var 1
|
||||
printf("11: Óäàëèòü çàäàííûé èíäåêñîì ýëåìåíò\n");
|
||||
printf("12: Âñòàâêà íîâîãî ýëåìåíòà\n");
|
||||
printf("13: Óäàëèòü ìèíèìàëüíûé ýëåìåíò\n");
|
||||
printf("14: Ïåðåä ìèíèìàëüíûì ýëåìåíòîì âñòàâèòü 0\n");
|
||||
printf("15: Óäàëèòü ïåðâûé èç ÷åòíûõ ýëåìåíòîâ\n");
|
||||
printf("\n");
|
||||
printf("0: Âûéòè èç ïðîãðàììû\n");
|
||||
|
||||
scanf_s("%d", &item);
|
||||
switch (item) {
|
||||
case 1:
|
||||
InputKey();
|
||||
break;
|
||||
case 2:
|
||||
x10();
|
||||
break;
|
||||
case 3: {
|
||||
int min = minNum();
|
||||
printf("Minimun in %d\n", min);
|
||||
}
|
||||
break;
|
||||
case 4: {
|
||||
int cnt = count10();
|
||||
printf("Total nums higher 10 is %d\n", cnt);
|
||||
}
|
||||
break;
|
||||
case 5: {
|
||||
int index = x2ForLast();
|
||||
if (index >= 0) {
|
||||
arr[index] *= 2;
|
||||
printf("That num now is %d", arr[index]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 6: {
|
||||
int index1 = findIndexMin();
|
||||
printf("Index of min num is %d\n", index1);
|
||||
|
||||
int cnt = 0;
|
||||
for (int i = 0; i <= index1; i++) {
|
||||
if (arr[i] % 2 == 0) {
|
||||
cnt++;
|
||||
}
|
||||
}
|
||||
printf("Ëåâåå ìèíèìàëüíîãî %d ÷åòíûõ ýëåìåíòîâ\n", cnt);
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
seven();
|
||||
break;
|
||||
case 8:
|
||||
eight();
|
||||
break;
|
||||
case 9:
|
||||
nine();
|
||||
break;
|
||||
case 11: {
|
||||
printf("Index deleting element = ");
|
||||
int index1;
|
||||
scanf_s("%d", &index1);
|
||||
deleteElement(index1);
|
||||
break;
|
||||
}
|
||||
|
||||
case 12:
|
||||
{
|
||||
printf("Ïåðåä êàêèì ýëåìåíòîì ñòàâèòü íîâûé? Èíäåêñ = ");
|
||||
int index;
|
||||
scanf_s("%d", &index);
|
||||
|
||||
printf("\nÇíà÷åíèå = ");
|
||||
int value;
|
||||
scanf_s("%d", &value);
|
||||
|
||||
insertElement(index, value);
|
||||
break;
|
||||
}
|
||||
case 13: {
|
||||
int min = minNum1();
|
||||
deleteElement(min);
|
||||
break;
|
||||
}
|
||||
case 14: {
|
||||
int min = minNum1();
|
||||
insertElement(min, 0);
|
||||
break;
|
||||
}
|
||||
case 15:
|
||||
LastTask();
|
||||
break;
|
||||
}
|
||||
|
||||
} while (item != 0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user