Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions homework/Header.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#pragma once
#include <vector>
#include <cmath>
#include <iostream>

std::vector<double> solve(double a, double b, double c);
13 changes: 8 additions & 5 deletions hw.cpp/functions.cpp → homework/functions.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include "Header.hpp"

std::vector<double> solve(double a, double b, double c) {
if (a == 0) {
throw std::invalid_argument("Coefficient 'a' can't be zero.");
}
std::vector<double>res;
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;
}
}
18 changes: 9 additions & 9 deletions hw.cpp/hw.cpp.sln → homework/homework.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 4 additions & 5 deletions hw.cpp/hw.cpp.vcxproj → homework/homework.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,9 @@
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{5861813b-a2f6-4aff-a225-42ed788a9f92}</ProjectGuid>
<RootNamespace>hwcpp</RootNamespace>
<ProjectGuid>{abf24fd9-a54b-4309-8932-f9cbf777409b}</ProjectGuid>
<RootNamespace>homework</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<ProjectName>hw1.cpp</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
Expand Down Expand Up @@ -128,11 +127,11 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="hww.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="functions.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Header.hpp" />
<ClInclude Include="Header.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="hww.cpp">
<ClCompile Include="main.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="functions.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Header.hpp">
<ClInclude Include="Header.h">
<Filter>Файлы заголовков</Filter>
</ClInclude>
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions hw.cpp/hww.cpp → homework/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "Header.hpp"
#include <iostream>

int main() {
double a, b, c;
Expand Down
6 changes: 0 additions & 6 deletions hw.cpp/Header.hpp

This file was deleted.