Explorar o código

Добавьте файлы проекта.

semen hai 4 días
pai
achega
e1c67c353c
Modificáronse 4 ficheiros con 458 adicións e 0 borrados
  1. 31 0
      InControl.sln
  2. 135 0
      InControl/InControl.vcxproj
  3. 22 0
      InControl/InControl.vcxproj.filters
  4. 270 0
      InControl/Main.c

+ 31 - 0
InControl.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.9.34723.18
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InControl", "InControl\InControl.vcxproj", "{03AA7A3E-E817-4044-8304-7E56EA12397A}"
+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
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Debug|x64.ActiveCfg = Debug|x64
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Debug|x64.Build.0 = Debug|x64
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Debug|x86.ActiveCfg = Debug|Win32
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Debug|x86.Build.0 = Debug|Win32
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Release|x64.ActiveCfg = Release|x64
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Release|x64.Build.0 = Release|x64
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Release|x86.ActiveCfg = Release|Win32
+		{03AA7A3E-E817-4044-8304-7E56EA12397A}.Release|x86.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {1293D8AA-1A20-4CD5-9C83-717E3A8F88F3}
+	EndGlobalSection
+EndGlobal

+ 135 - 0
InControl/InControl.vcxproj

@@ -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>{03aa7a3e-e817-4044-8304-7e56ea12397a}</ProjectGuid>
+    <RootNamespace>InControl</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 - 0
InControl/InControl.vcxproj.filters

@@ -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>

+ 270 - 0
InControl/Main.c

@@ -0,0 +1,270 @@
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+void calculateSquareEquation(float a, float b, float c, float* x1, float* x2) {
+    float D;
+    D = b * b - 4 * a * c;
+    if (a == 0) {
+        *x1 = -c / b;
+    }
+    else if (D > 0) {
+        *x1 = (-b + sqrt(D)) / (2 * a);
+        *x2 = (-b - sqrt(D)) / (2 * a);
+    }
+    else if (D == 0) {
+        *x1 = -b / (2 * a);
+    }    
+}
+
+void SLU(float a, float b, float c, float a1, float b1, float c1, float* x1, float* x2) {
+    
+        float d;
+        d = a * b1 - a1 * b;
+        if (d)
+        {
+            *x1 = (c * b1 - c1 * b) / d;
+            *x2 = (a * c1 - a1 * c) / d;
+        }
+
+}
+
+void inputData(int a,int* f, float* a1, float* b1, float* c1, float* a2, float* b2, float* c2)
+{
+    char buf[100];
+    switch (a) {
+    case 1:
+        for (;;)
+        {
+            printf("Ââåäèòå a: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", a1, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        for (;;)
+        {
+            printf("Ââåäèòå b: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", b1, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        for (;;)
+        {
+            printf("Ââåäèòå c: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", c1, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        break;
+    case 2:
+        for (;;)
+        {
+            printf("Ââåäèòå a1: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", a1, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        for (;;)
+        {
+            printf("Ââåäèòå b1: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", b1, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        for (;;)
+        {
+            printf("Ââåäèòå c1: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", c1, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        for (;;)
+        {
+            printf("Ââåäèòå a2: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", a2, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        for (;;)
+        {
+            printf("Ââåäèòå b2: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", b2, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        for (;;)
+        {
+            printf("Ââåäèòå c2: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%f %n", c2, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå 1 ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        break;
+    case 3:
+        for (;;)
+        {
+            printf("Ââåäèòå a: ");
+            if (fgets(buf, sizeof buf, stdin) == NULL) {
+                printf("Input closed\n");
+                break;
+            }
+            int n;
+            if (sscanf_s(buf, "%d %n", f, &n) == 1 && buf[n] == '\0')
+            {
+                break;
+            }
+            printf("<%s> ýòî íå öåëîå ÷èñëî. Ïîïðîáóé åùå ðàç\n", buf);
+        }
+        break;
+    }
+}
+
+void GetData(int a,int f, float x1, float x2)
+{
+    switch (a) {
+    case 1:
+        if (x1 != 0 && x2 != 0)
+        {
+            printf("Êîðíè óðàâíåíèÿ x1 = %f x2 = %f", x1,x2);
+        }
+        else if(x1 != 0)
+        {
+            printf("Êîðåíü óðàâíåíèÿ x = %f", x1);
+        }
+        else
+        {
+            printf("Êîðíåé íåò");
+        }
+        break;
+    case 2:
+        if (x1 == 0 && x2 == 0)
+        {
+            printf("Ñóùåñòâóåò áåñêîíå÷íîå ìíîæåñòâî ðåøåíèé");
+        }
+        else
+        {
+            printf("X ðàâåí %f Y ðàâåí %f", x1, x2);
+        }
+        break;
+    case 3:
+        printf("Ôàêòîðèàëà ðàâåí %d", f);
+        break;
+    }
+}
+
+void Factorial(int* f)
+{
+    int x, xF, d;
+    xF = *f;
+    x = xF;
+    for (d = 1;d < x;d++)
+    {
+        xF = xF * (x - d);
+    }
+    *f = xF;
+}
+
+void main() 
+{
+    system("chcp 1251");
+    float a1, b1, c1, a2, b2, c2, x1 = 0, x2 = 0;
+    int a,f = 0;
+    char buf[100];
+    printf("Âûáåðåòå íîìåð çàäàíèÿ: \n");
+    printf("1. Êâàäðàòíîå óðàâíåíèå. \n");
+    printf("2. Ñèñòåìà äâóõ ëèíåéíûõ óðàâíåíèé. \n");
+    printf("3. Ïåðåñòàíîâêè (ôàêòîðèàë). \n");
+    for (;;) 
+    {
+        if (fgets(buf, sizeof buf, stdin) == NULL) {
+            printf("Input closed\n");
+            break;
+        }
+        int n;
+        if (sscanf_s(buf, "%d %n", &a, &n) == 1 && buf[n] == '\0' && a >= 1 && a <=3)
+        {
+            break;
+        }
+        printf("<%s> ýòî íå íîìåð çàäàíèÿ. Ïîïðîáóé åùå ðàç.\n", buf);
+    }
+    switch (a) {
+    case 1:
+        inputData(a,&f, &a1, &b1, &c1, &a2, &b2, &c2);
+        calculateSquareEquation(a1, b1, c1, &x1, &x2);
+        GetData(a,f, x1, x2);
+        break;
+    case 2:
+        inputData(a, &f, &a1, &b1, &c1, &a2, &b2, &c2);
+        SLU(a1, b1, c1, a2, b2, c2, &x1, &x2);
+        GetData(a, f, x1, x2);
+        break;
+    case 3:
+        inputData(a, &f, &a1, &b1, &c1, &a2, &b2, &c2);
+        Factorial(&f);
+        GetData(a,f, x1, x2);
+        break;
+    }
+}