Сравнить коммиты
1 Коммитов
d70342b86c
...
master
| Автор | SHA1 | Дата | |
|---|---|---|---|
| ea387ac0b3 |
7106
project/doctest.h
Обычный файл
7106
project/doctest.h
Обычный файл
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@@ -2,6 +2,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void
|
void
|
||||||
find_minmax(vector<double> numbers, double& min, double& max) {
|
find_minmax(vector<double> numbers, double& min, double& max) {
|
||||||
min = numbers[0];
|
min = numbers[0];
|
||||||
@@ -18,7 +19,7 @@ find_minmax(vector<double> numbers, double& min, double& max) {
|
|||||||
|
|
||||||
vector<size_t>
|
vector<size_t>
|
||||||
make_histogram(vector<double> numbers, size_t bin_count) {
|
make_histogram(vector<double> numbers, size_t bin_count) {
|
||||||
vector <size_t> bins(bin_count);
|
vector <size_t> bins(bin_count, 0);
|
||||||
double min, max;
|
double min, max;
|
||||||
find_minmax(numbers, min, max);
|
find_minmax(numbers, min, max);
|
||||||
size_t countt;
|
size_t countt;
|
||||||
|
|||||||
6
project/histogram_internal.h
Обычный файл
6
project/histogram_internal.h
Обычный файл
@@ -0,0 +1,6 @@
|
|||||||
|
#ifndef HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
|
#define HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
void find_minmax(std::vector<double> numbers, double &min, double &max);
|
||||||
|
#endif // HISTOGRAM_INTERNAL_H_INCLUDED
|
||||||
@@ -3,10 +3,12 @@
|
|||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "svg.h"
|
#include "svg.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
struct Input {
|
struct Input {
|
||||||
vector<double> numbers;
|
vector<double> numbers;
|
||||||
size_t bin_count{};
|
size_t bin_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
Input
|
Input
|
||||||
@@ -18,14 +20,17 @@ input_data(){
|
|||||||
in.numbers.resize(number_count);
|
in.numbers.resize(number_count);
|
||||||
for(int i;i<number_count;i++)
|
for(int i;i<number_count;i++)
|
||||||
{
|
{
|
||||||
|
cerr << i + 1 << ": ";
|
||||||
cin >> in.numbers[i];
|
cin >> in.numbers[i];
|
||||||
}
|
}
|
||||||
cerr << "Enter bin count: ";
|
cerr << "Enter bin count: ";
|
||||||
cin >> in.bin_count;
|
cin >> in.bin_count;
|
||||||
|
getchar();
|
||||||
return in;
|
return in;
|
||||||
}
|
}
|
||||||
int main()
|
int main()
|
||||||
{ Input in = input_data();
|
{
|
||||||
|
Input in = input_data();
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
show_histogram_svg(bins);
|
show_histogram_svg(bins);
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef SVG_H_INCLUDED
|
#ifndef SVG_H_INCLUDED
|
||||||
#define SVG_H_INCLUDED
|
#define SVG_H_INCLUDED
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_svg(const std::vector<size_t>& bins);
|
show_histogram_svg(const std::vector<size_t>& bins);
|
||||||
|
|
||||||
|
|||||||
3
project/test.html
Обычный файл
3
project/test.html
Обычный файл
@@ -0,0 +1,3 @@
|
|||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<svg width='400' height='300' viewBox='0 0 400 300' xmlns='http://www.w3.org/2000/svg'>
|
||||||
|
<rect x='0' y='0' width='175' height='30' stroke='white' fill='#ffffff' /><text x='360' y='20'>1</text><rect x='175' y='0' width='175' height='30' stroke='red' fill='#aaffaa' /><rect x='0' y='30' width='175' height='30' stroke='white' fill='#ffffff' /><text x='360' y='50'>1</text><rect x='175' y='30' width='175' height='30' stroke='red' fill='#aaffaa' /><rect x='0' y='60' width='0' height='30' stroke='white' fill='#ffffff' /><text x='360' y='80'>2</text><rect x='0' y='60' width='350' height='30' stroke='red' fill='#aaffaa' /></svg>
|
||||||
|
После Ширина: | Высота: | Размер: 665 B |
@@ -2,7 +2,9 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include "text.h"
|
#include "text.h"
|
||||||
#include "histogram.h"
|
#include "histogram.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_text(vector<size_t> bins, size_t bin_count){
|
show_histogram_text(vector<size_t> bins, size_t bin_count){
|
||||||
const size_t SCREEN_WIDTH = 80;
|
const size_t SCREEN_WIDTH = 80;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#ifndef TEXT_H_INCLUDED
|
#ifndef TEXT_H_INCLUDED
|
||||||
#define TEXT_H_INCLUDED
|
#define TEXT_H_INCLUDED
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_text(std::vector<size_t> bins, size_t bin_count);
|
show_histogram_text(std::vector<size_t> bins, size_t bin_count);
|
||||||
|
|||||||
12
project/unittest.cpp
Обычный файл
12
project/unittest.cpp
Обычный файл
@@ -0,0 +1,12 @@
|
|||||||
|
#define DOCTEST_CONFIG_NO_MULTITHREADING
|
||||||
|
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||||
|
#include "histogram_internal.h"
|
||||||
|
#include "doctest.h"
|
||||||
|
|
||||||
|
TEST_CASE("distinct positive numbers") {
|
||||||
|
double min = 0;
|
||||||
|
double max = 0;
|
||||||
|
find_minmax({1, 2}, min, max);
|
||||||
|
CHECK(min == 1);
|
||||||
|
CHECK(max == 2);
|
||||||
|
}
|
||||||
Ссылка в новой задаче
Block a user