code: изменен ввод и вывод
Этот коммит содержится в:
2
.gitignore
поставляемый
2
.gitignore
поставляемый
@@ -10,3 +10,5 @@
|
||||
/unittest.layout
|
||||
/start.sh
|
||||
/cs-lab34
|
||||
/start
|
||||
/main.o
|
||||
|
||||
47
main.cpp
47
main.cpp
@@ -3,13 +3,14 @@
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <curl/curl.h>
|
||||
#include "histogram.h"
|
||||
#include "text.h"
|
||||
#include "svg.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct Input {
|
||||
struct Input { //data input
|
||||
vector<double> numbers;
|
||||
size_t bin_count{};
|
||||
size_t interval_task{};
|
||||
@@ -17,35 +18,45 @@ struct Input {
|
||||
|
||||
|
||||
Input
|
||||
input_data() {
|
||||
size_t number_count;
|
||||
cin >> number_count;
|
||||
input_data(istream& in, bool prompt) { //input data structure
|
||||
|
||||
Input in;
|
||||
|
||||
in.numbers.resize(number_count);
|
||||
for (size_t i = 0; i < number_count; i++) {
|
||||
cin >> in.numbers[i];
|
||||
if (prompt == false) { //prompt output
|
||||
cerr.rdbuf(NULL);
|
||||
}
|
||||
|
||||
cin >> in.bin_count;
|
||||
size_t number_count;
|
||||
cerr << "Enter number count: \n";
|
||||
cerr.flush();
|
||||
in >> number_count;
|
||||
|
||||
cin >> in.interval_task;
|
||||
Input in_data_struct;
|
||||
|
||||
if ((in.interval_task >= 2.0) && (in.interval_task <= 9.0)) {
|
||||
return in;
|
||||
in_data_struct.numbers.resize(number_count);
|
||||
for (size_t i = 0; i < number_count; i++) {
|
||||
cerr << "Enter number "<< i << " : \n";
|
||||
in >> in_data_struct.numbers[i];
|
||||
}
|
||||
|
||||
cerr << "Enter bin count: \n";
|
||||
in >> in_data_struct.bin_count;
|
||||
|
||||
cerr << "Enter interval from task: \n";
|
||||
in >> in_data_struct.interval_task;
|
||||
|
||||
if ((in_data_struct.interval_task >= 2.0) && (in_data_struct.interval_task <= 9.0)) { //scale interval size check
|
||||
return in_data_struct;
|
||||
} else {
|
||||
std::cout << "ERROR";
|
||||
std::cout << "ERROR"; //error situation and program exit
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
auto in = input_data();
|
||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||
show_histogram_svg(bins, in.interval_task);
|
||||
//curl_global_init(CURL_GLOBAL_ALL);
|
||||
auto in = input_data(cin, true); //input data
|
||||
auto bins = make_histogram(in.numbers, in.bin_count); //calculating bin size for the histogram
|
||||
show_histogram_svg(bins, in.interval_task); //histogram output in the format svg code
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user