This commit is contained in:
yuran4ik 2024-11-19 22:09:32 +04:00
parent a11a753023
commit 5b4d38655c
7 changed files with 679 additions and 0 deletions

2
lab/desktop.ini Normal file
View File

@ -0,0 +1,2 @@
[.ShellClassInfo]
IconResource=C:\Program Files\Google\Drive File Stream\100.0.2.0\GoogleDriveFS.exe,26

138
lab/lab.vcxproj Normal file
View File

@ -0,0 +1,138 @@
<?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>{84206dea-52a8-4fdc-88ae-19eab48f0d52}</ProjectGuid>
<RootNamespace>lab</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="lab1.c" />
<ClCompile Include="lab2.c" />
<ClCompile Include="lab3.c" />
<ClCompile Include="lab4.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

31
lab/lab.vcxproj.filters Normal file
View File

@ -0,0 +1,31 @@
<?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="lab1.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="lab2.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="lab3.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="lab4.c">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
</Project>

57
lab/lab1.c Normal file
View File

@ -0,0 +1,57 @@
#include <stdio.h>
#include <locale.h>
void aboutMe() {
printf("Øëÿïèí\nÞðèé\nÀëåêñàíäðîâè÷\n");
printf("ÏÈáä-12\n");
printf("24.09.2024\n");
printf("Îñíîâû àëãîðèòìèçàöèè è ïðîãðàììèðîâàíèÿ\n");
printf("ËÐ 8\n\n");
}
int main1() {
setlocale(LC_ALL, "RU");
aboutMe();
//printf("Hello World!\n\n\n");
//printf("Øëÿïèí Þðèé Àëåêñàíäðîâè÷\n");
//printf("ÏÈáä-12\n");
//printf("04.09.2024\n\n");
//printf("04.09.2024\n");
//printf("ÏÈáä-12\n");
//printf("Øëÿïèí Þðèé Àëåêñàíäðîâè÷\n\n\n");
//printf("Øëÿïèí Þðèé Àëåêñàíäðîâè÷\n");
//printf("ÏÈáä-12\n");
//printf("04.09.2024\n\n");
//printf("04.09.2024\n");
//printf("ÏÈáä-12\n");
//printf("Øëÿïèí Þðèé Àëåêñàíäðîâè÷\n\n\n");
/*printf(" * \n");
printf(" * * * \n");
printf(" * * * \n");
printf("* * * * * * *\n");
printf(" * * * \n");
printf(" * * * \n");
printf(" / * \\ \n");
printf(" // * \\\\ \n");
printf(" /// * \\\\\\ \n");
printf("__//// * \\\\\\\\__\n");*/
//printf(" *-----*\n");
//printf(" / /|\n");
//printf("*-----* |\n");
//printf("| | |\n");
//printf("| | |\n");
//printf("| |/\n");
//printf("*-----*\n");
//printf("\n");
//printf("\n");
return 0;
}

104
lab/lab2.c Normal file
View File

@ -0,0 +1,104 @@
#include <stdio.h>
#include <windows.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define g 9.8f
void L2Z1(), L2Z2(), L2Z3(), L2Z4(), L2Z5(), L2Z6(), L2Z7();
int main2() {
system("chcp 1251");
//L2Z1();
//L2Z2();
//L2Z3();
//L2Z4();
//L2Z5();
//L2Z6();
L2Z7();
return 0;
}
void L2Z1() {
float h = 12, t = sqrt(2 * h / g);
printf("Êàìåíü óïàäåò çà %.2f ñåêóíä\n", t);
}
void L2Z2() {
float h, t;
printf("Ââåäèòå âûñîòó: ");
scanf_s("%f", &h);
t = sqrt(2 * h / g);
printf("Êàìåíü óïàäåò çà %.2f ñåêóíä", t);
}
void L2Z3() {
float S;
int cost_per_meter;
printf("Ââåäèòå ïëîùàäü è öåíó çà êâ.ì: ");
scanf_s("%f%d", &S, &cost_per_meter);
float price = S * cost_per_meter;
printf("%.2f", price);
}
void L2Z4() {
float S, percent = 0.5;
int cost_per_meter, salary;
printf("Ââåäèòå ïëîùàäü êâàðòèðû: ");
scanf_s("%f", &S);
printf("Ââåäèòå ñòîèìîñòü 1 êâ.ì: ");
scanf_s("%d", &cost_per_meter);
printf("Ââåäèòå çàðïëàòó: ");
scanf_s("%d", &salary);
printf("êâàðòèðà ïëîùàäüþ %f ïî öåíå %d çà êâ.ì ñòîèò %f\n", S, cost_per_meter, S * cost_per_meter);
float t = (S * cost_per_meter) / (salary * percent);
printf("ïðè çàðïëàòå %d íóæíî êîïèòü %1.2f ìåñ", salary, t);
}
void L2Z5() {
float V, R, H;
printf("íàõîæäåíèå îáúåìà øàðîâîãî ñåãìåíòà\n");
printf("Ââåäèòå ðàäèóñ øàðà: ");
scanf_s("%f", &R);
printf("Ââåäèòå âûñîòó øàðîâîãî ñåãìåíòà: ");
scanf_s("%f", &H);
if (H > 2 * R) H = 2 * R;
V = M_PI * pow(H, 2) * (R - H / 3);
printf("V øàðîâîãî ñåãìåíòà = %.2f", V);
}
void L2Z6() {
float V, a;
printf("Âû÷èñëåíèå ïóòè ïðè áàëëèñòè÷åñêîì äâèæåíèè\n");
printf("Ââåäèòå íà÷àëüíóþ ñêîðîòü: ");
scanf_s("%f", &V);
printf("Ââåäèòå óãîë â ãðàäóñàõ: ");
scanf_s("%f", &a);
float S = pow(V, 2) * sinf(2 * a * M_PI / 180) / g;
float H = pow(V * sinf(a * M_PI / 180), 2) / 2 / g;
printf("L = %.2f\n", S);
printf("H = %.2f\n\n", H);
}
void L2Z7() {
float A, r;
int n;
char currency[4];
printf("Ðàññ÷èòûâàåò ñóììó âûïëàò è ïåðåïëàòó ïî êðåäèòó\n");
printf("Ââåäèòå ñóììó çàéìà: ");
scanf_s("%f", &A);
printf("Ââåäèòå êîëè÷åñòâî ìåñÿöåâ: ");
scanf_s("%d", &n);
printf("Ââåäèòå ïðîöåíòíóþ ñòàâêó: ");
scanf_s("%f", &r);
printf("Ââåäèòå âàëþòó: ");
scanf_s("%s", currency, 4);
float S = A + ((A + A / n) * r * n / 2 / 100);
printf("Ñóììà âûïëàò %.2f %s\nÏåðåïëàòà %.2f %s\n\n", S, currency, S - A, currency);
}

217
lab/lab3.c Normal file
View File

@ -0,0 +1,217 @@
#include <stdio.h>
#include <locale.h>
void L3Z1();
int L3Z2();
char* L3Z3();
int L3Z4();
char* L3Z5();
char* L3Z6();
char* L3Z7();
int main3() {
setlocale(LC_ALL, "RU");
//L3Z1();
//L3Z2();
//L3Z3();
//L3Z4();
//L3Z5();
//L3Z6();
//L3Z7();
return 0;
}
void L3Z1() {
float a, b;
printf("ââåäèòå ïåðâîå ÷èñëî: ");
scanf_s("%f", &a);
printf("ââåäèòå âòîðîå ÷èñëî: ");
scanf_s("%f", &b);
if (a == b) {
printf("Ââåäåííûå ÷èñëà ðàâíû");
}
else {
float max, min;
if (a > b) {
max = a;
min = b;
}
else {
max = b;
min = a;
}
printf("Íàèáîëüøåå ÷èñëî = %f\nÍàèìåíüøåå ÷èñëî = %f", max, min);
}
}
int L3Z2() {
int a, b, c;
printf("ââåäèòå 3 ÷èñëà: ");
scanf_s("%d %d %d", &a, &b, &c);
int max = a;
if (b > max) {
max = b;
}
if (c > max) {
max = c;
}
printf("max = %d", max);
return max;
}
char* L3Z3() {
int temperature;
char* ans = "";
printf("ââåäèòå òåìïåðàòóðó: ");
scanf_s("%d", &temperature);
if (temperature >= 18 && temperature < 22) {
ans = "õîëîäíî";
}
else if (temperature >= 22 && temperature < 26) {
ans = "òåëî";
}
else if (temperature >= 26) {
ans = "æàðêî";
}
printf("%s", ans);
return ans;
}
int L3Z4() {
int a[5];
printf("ââåäèòå 5 ÷èñåë: ");
for (int i = 0; i < 5; i++) {
scanf_s("%d", &a[i]);
}
int max = a[0];
for (int i = 1; i < 5; i++) {
if (a[i] > max) {
max = a[i];
}
}
printf("%d", max);
return max;
}
/*
tests:
input | output
1 | ìîðîç
2 | òåïëî
3 | æàðêî
4 | õîëîäíî
*/
char* L3Z5() {
char* ans = "";
int season;
printf("âûáåðèòå âðåìÿ ãîäà\n");
printf("1) çèìà\n");
printf("2) âåñíà\n");
printf("3) ëåòî\n");
printf("4) îñåíü\n");
scanf_s("%d", &season);
while (!(1 <= season && season <= 4)) {
printf("âûáåðèòå êîððåêòíîå âðåìÿ ãîäà\n");
printf("1) çèìà\n");
printf("2) âåñíà\n");
printf("3) ëåòî\n");
printf("4) îñåíü\n");
scanf_s("%d", &season);
}
if (season == 1) {
ans = "ìîðîç";
}
else if (season == 2) {
ans = "òåïëî";
}
else if (season == 3) {
ans = "æàðêî";
}
else {
ans = "õîëîäíî";
}
printf("%s", ans);
return ans;
}
/*
tests:
input | output
1 | äåøåâî
264000 | íîðìàëüíî
3567904 | óæàñ äîðîãî
*/
char* L3Z6() {
float price;
char* ans = "";
printf("öåíà íà ìèíèâýí = ");
scanf_s("%f", &price);
if (price <= 250000) {
ans = "äåøåâî";
}
else if (price > 250000 && price <= 700000) {
ans = "íîðìàëüíî";
}
else if (price > 700000 && price <= 1000000) {
ans = "äîðîãî";
}
else if (price > 1000000 && price <= 100000000) {
ans = "óæàñ äîðîãî";
}
printf("%s", ans);
return ans;
}
/*
tests:
input | output
1 | ìãíîâåííî
123 | áûñòðî
735 | íîðìàëüíî
9090 | î÷åíü ìåäëåííî
*/
char* L3Z7() {
float ms;
char* ans = "";
printf("ñêîðîñòü âûïîëíåíèÿ ïðîãðàììû = ");
scanf_s("%f", &ms);
if (ms <= 1) {
ans = "ìãíîâåííî";
}
else if (ms > 1 && ms <= 2) {
ans = "î÷åíü áûñòðî";
}
else if (ms > 2 && ms <= 100) {
ans = "áûñòðî";
}
else if (ms > 100 && ms <= 1000) {
ans = "íîðìàëüíî";
}
else if (ms > 1000 && ms <= 5000) {
ans = "ìåäëåííî";
}
else if (ms > 5000 && ms <= 10000) {
ans = "î÷åíü ìåäëåííî";
}
printf("%s", ans);
return ans;
}

130
lab/lab4.c Normal file
View File

@ -0,0 +1,130 @@
#include <stdio.h>
#include <stdbool.h>
#include <locale.h>
#include <math.h>
void L4Z1(), L4Z2(), L4Z3(), L4Z4(), L4Z5(), L4Z6(), L4Z7();
int main4() {
setlocale(LC_ALL, "RU");
//L4Z1();
//L4Z2();
//L4Z3();
//L4Z4();
//L4Z4();
//L4Z5();
//L4Z6();
//L4Z7();
return 0;
}
void L4Z1() {
int n, i = 1;
printf("n = ");
scanf_s("%d", &n);
do {
printf("%d ", i);
i++;
} while (i <= n);
}
void L4Z2() {
int n, stepen = 1, i = 0;
printf("n = ");
scanf_s("%d", &n);
do {
printf("%d^%d = %d\n", n, i, stepen);
stepen *= n;
i++;
} while (i <= 5);
}
void L4Z3() {
float summa, percent;
int i = 0;
printf("summa = ");
scanf_s("%f", &summa);
printf("percent = ");
scanf_s("%f", &percent);
do {
printf("%2d year summa = %10.0f\n", i, summa);
summa *= (percent / 100 + 1);
i++;
} while (i <= 10);
}
void L4Z4() {
int n, i = 1;
scanf_s("%d", &n);
do {
printf("%d ", 2 * i);
i++;
} while (i <= n);
}
void L4Z5() {
int n, a, i = 1;
scanf_s("%d", &n);
scanf_s("%d", &a);
do {
printf("%d ", a * i);
i++;
} while (i <= n);
}
void L4Z6() {
int i = 2;
int n;
scanf_s("%d", &n);
do {
bool ok = true;
int del = 2;
while (del < ((int)sqrt(i)) + 1) {
if ((i % del) == 0) {
ok = false;
break;
}
del++;
}
/*for (int del = 2; del < ((int)sqrt(i)) + 1; del++) {
if ((i % del) == 0) {
ok = false;
break;
}
}*/
if (ok) {
printf("%d ", i);
n--;
}
i++;
} while (n > 0);
}
void L4Z7() {
int summ, transh, n;
float percent;
summ = 1000000, transh = 1000000, n = 3, percent = 18;
printf("summ, transh, n, percent");
scanf_s("%d%d%d%f", &summ, &transh, &n, &percent);
do {
summ = summ * (percent / 100 + 1) - transh;
n--;
} while (n > 0);
printf("%d", summ);
}