diff --git a/homework/Header.hpp b/homework/Header.hpp new file mode 100644 index 0000000..bc693b4 --- /dev/null +++ b/homework/Header.hpp @@ -0,0 +1,6 @@ +#pragma once +#include +#include +#include + +std::vector solve(double a, double b, double c); \ No newline at end of file diff --git a/hw.cpp/functions.cpp b/homework/functions.cpp similarity index 60% rename from hw.cpp/functions.cpp rename to homework/functions.cpp index ed311f5..7985a6f 100644 --- a/hw.cpp/functions.cpp +++ b/homework/functions.cpp @@ -1,13 +1,16 @@ #include "Header.hpp" std::vector solve(double a, double b, double c) { - if (a == 0) { - throw std::invalid_argument("Coefficient 'a' can't be zero."); - } std::vectorres; double diskr = b * b - 4 * a * c; - + + if (diskr < 0) { + std::exception ex("Roots are not real, diskriminant < 0"); + cout << ex.what(); + exit(1); + } + double diskr = b * b - 4 * a * c; res.push_back((-b + sqrt(diskr)) / (2 * a)); res.push_back((-b - sqrt(diskr)) / (2 * a)); return res; -} \ No newline at end of file +} diff --git a/hw.cpp/hw.cpp.sln b/homework/homework.sln similarity index 50% rename from hw.cpp/hw.cpp.sln rename to homework/homework.sln index 642f965..b10d28b 100644 --- a/hw.cpp/hw.cpp.sln +++ b/homework/homework.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.12.35527.113 d17.12 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "hw.cpp", "hw.cpp.vcxproj", "{5861813B-A2F6-4AFF-A225-42ED788A9F92}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "homework", "homework.vcxproj", "{ABF24FD9-A54B-4309-8932-F9CBF777409B}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +13,14 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Debug|x64.ActiveCfg = Debug|x64 - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Debug|x64.Build.0 = Debug|x64 - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Debug|x86.ActiveCfg = Debug|Win32 - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Debug|x86.Build.0 = Debug|Win32 - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Release|x64.ActiveCfg = Release|x64 - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Release|x64.Build.0 = Release|x64 - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Release|x86.ActiveCfg = Release|Win32 - {5861813B-A2F6-4AFF-A225-42ED788A9F92}.Release|x86.Build.0 = Release|Win32 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Debug|x64.ActiveCfg = Debug|x64 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Debug|x64.Build.0 = Debug|x64 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Debug|x86.ActiveCfg = Debug|Win32 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Debug|x86.Build.0 = Debug|Win32 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Release|x64.ActiveCfg = Release|x64 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Release|x64.Build.0 = Release|x64 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Release|x86.ActiveCfg = Release|Win32 + {ABF24FD9-A54B-4309-8932-F9CBF777409B}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/hw.cpp/hw.cpp.vcxproj b/homework/homework.vcxproj similarity index 96% rename from hw.cpp/hw.cpp.vcxproj rename to homework/homework.vcxproj index fe750bd..c805101 100644 --- a/hw.cpp/hw.cpp.vcxproj +++ b/homework/homework.vcxproj @@ -21,10 +21,9 @@ 17.0 Win32Proj - {5861813b-a2f6-4aff-a225-42ed788a9f92} - hwcpp + {abf24fd9-a54b-4309-8932-f9cbf777409b} + homework 10.0 - hw1.cpp @@ -128,11 +127,11 @@ - + - + diff --git a/hw.cpp/hw.cpp.vcxproj.filters b/homework/homework.vcxproj.filters similarity index 94% rename from hw.cpp/hw.cpp.vcxproj.filters rename to homework/homework.vcxproj.filters index 4d7bb0b..4ece200 100644 --- a/hw.cpp/hw.cpp.vcxproj.filters +++ b/homework/homework.vcxproj.filters @@ -15,7 +15,7 @@ - + Исходные файлы @@ -23,7 +23,7 @@ - + Файлы заголовков diff --git a/hw.cpp/hww.cpp b/homework/main.cpp similarity index 97% rename from hw.cpp/hww.cpp rename to homework/main.cpp index 94bc096..8968a25 100644 --- a/hw.cpp/hww.cpp +++ b/homework/main.cpp @@ -1,4 +1,5 @@ #include "Header.hpp" +#include int main() { double a, b, c; diff --git a/hw.cpp/Header.hpp b/hw.cpp/Header.hpp deleted file mode 100644 index 1e5aa07..0000000 --- a/hw.cpp/Header.hpp +++ /dev/null @@ -1,6 +0,0 @@ -#pragma once -#include -#include -#include -#include -std::vector solve(double a, double b, double c);