Исправлены замечания для защиты

master
GordiyevskikDA 1 год назад
Родитель 4a7ee50d89
Сommit c491c81842

@ -3,6 +3,7 @@
#include <vector> #include <vector>
#include "histogram.h" #include "histogram.h"
#include "text.h" #include "text.h"
using namespace std; using namespace std;
@ -67,6 +68,7 @@ struct Input {
Input input_data() { Input input_data() {
Input in; Input in;
Input in2;
int VecSize = 0; int VecSize = 0;
cin >> VecSize; cin >> VecSize;
in.marks.resize(VecSize); in.marks.resize(VecSize);

@ -5,6 +5,8 @@ VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LABA1", "LABA1.vcxproj", "{D164F324-4243-431D-90CA-53E6B0D0180A}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LABA1", "LABA1.vcxproj", "{D164F324-4243-431D-90CA-53E6B0D0180A}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unittest", "unittest.vcxproj", "{A913469C-7807-4128-B5B5-C49C6B34CDE3}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64 Debug|x64 = Debug|x64
@ -21,6 +23,14 @@ Global
{D164F324-4243-431D-90CA-53E6B0D0180A}.Release|x64.Build.0 = Release|x64 {D164F324-4243-431D-90CA-53E6B0D0180A}.Release|x64.Build.0 = Release|x64
{D164F324-4243-431D-90CA-53E6B0D0180A}.Release|x86.ActiveCfg = Release|Win32 {D164F324-4243-431D-90CA-53E6B0D0180A}.Release|x86.ActiveCfg = Release|Win32
{D164F324-4243-431D-90CA-53E6B0D0180A}.Release|x86.Build.0 = Release|Win32 {D164F324-4243-431D-90CA-53E6B0D0180A}.Release|x86.Build.0 = Release|Win32
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Debug|x64.ActiveCfg = Debug|x64
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Debug|x64.Build.0 = Debug|x64
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Debug|x86.ActiveCfg = Debug|Win32
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Debug|x86.Build.0 = Debug|Win32
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Release|x64.ActiveCfg = Release|x64
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Release|x64.Build.0 = Release|x64
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Release|x86.ActiveCfg = Release|Win32
{A913469C-7807-4128-B5B5-C49C6B34CDE3}.Release|x86.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

@ -127,7 +127,9 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="histogram.cpp" />
<ClCompile Include="LABA1.cpp" /> <ClCompile Include="LABA1.cpp" />
<ClCompile Include="text.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

@ -18,5 +18,11 @@
<ClCompile Include="LABA1.cpp"> <ClCompile Include="LABA1.cpp">
<Filter>Исходные файлы</Filter> <Filter>Исходные файлы</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="histogram.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
<ClCompile Include="text.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>

@ -3,18 +3,21 @@ using namespace std;
void FindMinMax(const vector<double>& marks, double& min, double& max) { void FindMinMax(const vector<double>& marks, double& min, double& max) {
max = 0; max = 0;
min = marks[0]; min = 0;
for (double x : marks) { if (marks.size() = 0) {
if (x > max) { min = marks[0];
max = x; for (double x : marks) {
} if (x > max) {
if (x < min) { max = x;
min = x; }
if (x < min) {
min = x;
}
} }
} }
}; }
static vector <double> MakeHistogram(const vector<double>& marks, int NCharts) { vector <double> MakeHistogram(const vector<double>& marks, int NCharts) {
double interval = 0, i = 0, min = 0, max = 0; double interval = 0, i = 0, min = 0, max = 0;
vector<double> chart(NCharts); vector<double> chart(NCharts);
FindMinMax(marks, min, max); FindMinMax(marks, min, max);
@ -27,4 +30,4 @@ static vector <double> MakeHistogram(const vector<double>& marks, int NCharts) {
chart[i] += 1; chart[i] += 1;
} }
return chart; return chart;
}; }

@ -1,8 +1,9 @@
#ifndef HISTOGRAM_H_INCLUDED #ifndef HISTOGRAM_H_INCLUDED
#define HISTOGRAM_H_INCLUDED #define HISTOGRAM_H_INCLUDED
#include "histogram.cpp" //Возможно, костыль. Но без этого не работает!
#include <vector> #include <vector>
void FindMinMax(const std::vector<double>& marks, double& min, double& max);
std::vector<double> MakeHistogram(const std::vector<double>& marks, int NCharts); std::vector<double> MakeHistogram(const std::vector<double>& marks, int NCharts);
#endif // HISTOGRAM_H_INCLUDED #endif // HISTOGRAM_H_INCLUDED

@ -1,6 +1,5 @@
#ifndef HISTOGRAM_H_INCLUDED #ifndef HISTOGRAM_H_INCLUDED
#define HISTOGRAM_H_INCLUDED #define HISTOGRAM_H_INCLUDED
#include "histogram.cpp"
#include <vector> #include <vector>
void FindMinMax(const std::vector<double>& marks, double& min, double& max); void FindMinMax(const std::vector<double>& marks, double& min, double& max);

@ -1,3 +1,4 @@
#include <iostream>
#include "histogram.h" #include "histogram.h"
using namespace std; using namespace std;

@ -1,8 +1,8 @@
#ifndef TEXT_H_INCLUDED #ifndef TEXT_H_INCLUDED
#define TEXT_H_INCLUDED #define TEXT_H_INCLUDED
#include "text.cpp" //Возможно, костыль. Но без этого не работает!
#include <vector> #include <vector>
void show_histogram_text(const vector<double>& marks, const vector<double>& chart); void show_histogram_text(const std::vector<double>& marks, const std::vector<double>& chart);
#endif // TEXT_H_INCLUDED #endif // TEXT_H_INCLUDED

@ -13,21 +13,13 @@ TEST_CASE("distinct positive numbers") {
CHECK(max == 2); CHECK(max == 2);
} }
/*
Если вектор пуст, искусственно добавляем в него значения
Проверяем, равны ли min и max этим искусственным значениям
*/
TEST_CASE("empty vector") { TEST_CASE("empty vector") {
double min = 0; double min = 0;
double max = 0; double max = 0;
vector <double> fortest; FindMinMax({ }, min, max);
if (fortest.size() == 0) { CHECK(min != 0);
fortest.push_back(90); CHECK(max != 0);
fortest.push_back(100);
}
FindMinMax(fortest, min, max);
CHECK(min != 90);
CHECK(max != 100);
} }
TEST_CASE("one element") { TEST_CASE("one element") {

@ -127,6 +127,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="histogram.cpp" />
<ClCompile Include="unittest.cpp" /> <ClCompile Include="unittest.cpp" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

@ -18,5 +18,8 @@
<ClCompile Include="unittest.cpp"> <ClCompile Include="unittest.cpp">
<Filter>Исходные файлы</Filter> <Filter>Исходные файлы</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="histogram.cpp">
<Filter>Исходные файлы</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
</Project> </Project>
Загрузка…
Отмена
Сохранить