Преглед изворни кода

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

Lera пре 3 дана
родитељ
комит
d7cd096216
4 измењених фајлова са 353 додато и 0 уклоњено
  1. 31 0
      Project1.sln
  2. 135 0
      Project1/Project1.vcxproj
  3. 22 0
      Project1/Project1.vcxproj.filters
  4. 165 0
      Project1/Source.c

+ 31 - 0
Project1.sln

@@ -0,0 +1,31 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.8.34511.84
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project1", "Project1\Project1.vcxproj", "{6E5A3720-78DE-4BE4-B77F-752899B160C3}"
+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
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Debug|x64.ActiveCfg = Debug|x64
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Debug|x64.Build.0 = Debug|x64
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Debug|x86.ActiveCfg = Debug|Win32
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Debug|x86.Build.0 = Debug|Win32
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Release|x64.ActiveCfg = Release|x64
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Release|x64.Build.0 = Release|x64
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Release|x86.ActiveCfg = Release|Win32
+		{6E5A3720-78DE-4BE4-B77F-752899B160C3}.Release|x86.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {E4E9CAF5-62F4-4AA2-9439-3F4EBEA299E5}
+	EndGlobalSection
+EndGlobal

+ 135 - 0
Project1/Project1.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>{6e5a3720-78de-4be4-b77f-752899b160c3}</ProjectGuid>
+    <RootNamespace>Project1</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="Source.c" />
+  </ItemGroup>
+  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+  <ImportGroup Label="ExtensionTargets">
+  </ImportGroup>
+</Project>

+ 22 - 0
Project1/Project1.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="Source.c">
+      <Filter>Исходные файлы</Filter>
+    </ClCompile>
+  </ItemGroup>
+</Project>

+ 165 - 0
Project1/Source.c

@@ -0,0 +1,165 @@
+
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <setjmp.h>
+
+
+
+
+
+
+int Input(float* a, float* b, float* c, float* a2, float* b2, float* c2, float choice)
+{
+    if (choice == 1)
+    {
+
+        printf("Ââåäèòå êîýôôèöèåíò a: \n");
+        scanf_s("%f", a);
+        printf("Ââåäèòå êîýôôèöèåíò b: \n");
+        scanf_s("%f", b);
+        printf("Ââåäèòå êîýôôèöèåíò c: \n");
+        scanf_s("%f", c);
+    }
+    else if (choice == 2)
+    {
+
+        printf("Ââåäèòå êîýôôèöèåíò x ïåðâîãî óðàâíåíèÿ: \n");
+        scanf_s("%f", a);            
+        printf("Ââåäèòå êîýôôèöèåíò y ïåðâîãî óðàâíåíèÿ: \n");
+        scanf_s("%f", b);            
+        printf("Ââåäèòå ÷åìó ðàâíî ïåðâîå óðàâíåíèå: \n");
+        scanf_s("%f", c);
+        printf("Ââåäèòå êîýôôèöèåíò õ âòîðîãî óðàâíåíèÿ: \n");
+        scanf_s("%f", a2);
+        printf("Ââåäèòå êîýôôèöèåíò ó âòîðîãî óðàâíåíèÿ: \n");
+        scanf_s("%f", b2);
+        printf("Ââåäèòå ÷åìó ðàâíî âòîðîå óðàâíåíèå: \n");
+        scanf_s("%f", c2);
+    }
+    else
+    {
+   
+        printf("Ââåäèòå ÷èñëî, ôàêòîðèàë êîòîðîãî õîòèòå âû÷èñëèòü: \n");
+        scanf_s("%f", a);
+    }
+
+    return 0;
+}
+
+
+void kramer(float a, float b, float c, float a2, float b2, float c2, float* res1, float* res2)
+{
+    float delta = a * b2 - a2 * b;
+    if (delta != 0)
+    {
+        float buf = (c * b2 - c2 * b) / delta;
+        float buf2 = (a * c2 - a2 * c) / delta;
+        *res1 = buf;
+        *res2 = buf2;
+    }
+    
+}
+
+void square(float a, float b, float c, float* res1, float* res2) 
+{
+    float discriminant;
+    discriminant = b * b - 4 * a * c;
+    if (discriminant < 0)
+    {
+        *res1 = 0;
+        *res2 = 0;
+    }
+    else if (discriminant > 0) 
+    {
+        *res1 = (-b + sqrt(discriminant)) / (2 * a);
+        *res2 = (-b - sqrt(discriminant)) / (2 * a);
+    }
+    else if (discriminant == 0)
+    {
+        * res1 = -b / (2 * a);
+        *res2 = 0;
+    }
+    else
+    {
+        //íà ñëó÷àé åñëè ïîëüçîâàòåëü ââåäåò íóëåâîé êîýôôèöèåíò à
+        *res1 = -c / b;
+        *res2 = 0;
+    }
+}
+
+void Factorial(float a, float* res1)
+{
+    float buf = 1;
+    for (int i = 1; i <= a; i++)
+    {
+        buf = buf * i;
+    }
+    *res1 = buf;
+
+    
+}
+
+
+int output(float a, float b, float c, float a2, float b2, float c2, float res1, float res2, int choice)
+{
+    if (choice == 1)
+    {
+        if (res1 != 0 && res2 != 0) printf("Êîðåíü õ1 ðàâåí  %-6.2f\nÊîðåíü õ2 ðàâåí  %-6.2f\n", res1, res2);
+        else if(res1!=0)  printf("Êîðåíü õ ðàâåí  %-6.2f\n", res1);
+        else printf("Êîðíåé íåò");
+       
+    }
+    else if (choice == 2)
+    {
+        printf("Êîðåíü õ ðàâåí  %-6.2f\nÊîðåíü ó ðàâåí  %-6.2f\n", res1, res2);
+    }
+    else
+    {
+        printf("Ôàêòîðèàë ÷èñëà  %-6.2f ðàâåí %-6.2f\n",a,res1);
+    }
+
+    return 0;
+}
+
+
+int main(void)
+{
+    float a, b, c, a2, b2, c2;
+    float res1;
+    float res2=0;
+    system("chcp 1251>nul");
+    int choice;
+    printf("Âûáåðèòå çàäàíèå: \n");
+    printf("1. êâàäðàòíîå óðàâíåíèå\n");
+    printf("2. ñèñòåìà äâóõ ëèíåéíûõ óðàâíåíèé\n");
+    printf("3. ïåðåñòàíîâêè (ôàêòîðèàë)\n");
+    scanf_s("%d", &choice);
+    int factorial, ResultFactorial;
+    switch (choice)
+    {
+    case 1:
+        printf("êâàäðàòíîå óðàâíåíèå\n");
+        Input(&a, &b, &c, &a2, &b2, &c2, choice);
+        square(a,b,c,&res1,&res2);
+        output(a, b, c, a2, b2, c2, res1, res2, choice);
+        break;
+    case 2:
+        printf("ñèñòåìà äâóõ ëèíåéíûõ óðàâíåíèé\n");
+        Input(&a, &b, &c, &a2, &b2, &c2, choice);
+        kramer(a, b, c, a2, b2, c2, &res1, &res2);
+        output(a, b, c, a2, b2, c2, res1, res2, choice);
+        
+        break;
+    case 3:
+        printf("ïåðåñòàíîâêè (ôàêòîðèàë)\n");
+        Input(&a, &b, &c, &a2, &b2, &c2, choice);
+        Factorial(a,&res1);
+        output(a, b, c, a2, b2, c2, res1, res2, choice);
+        break;
+    default:
+        printf("Òàêîãî çàäàíèÿ íåò\n");
+        break;
+    }
+}
+