Сравнить коммиты

..

Ничего общего в коммитах. 'c0aba9ac09107564628efa8feb6fea61655bc835' и '62b78372fa6195f32a60452fee2a3b421fa0211a' имеют совершенно разные истории.

@ -1,11 +1,8 @@
#include <iostream>
#include <cmath>
#include <vector>
#include "histogram.h"
#include "text.h"
#include "svg.h"
#include <curl/curl.h>
using namespace std;
const size_t SCREEN_WIDTH = 80;
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
@ -16,54 +13,31 @@ struct Input {
};
Input
input_data(istream& in, bool prompt) {
input_data() {
size_t number_count;
if (prompt == true){
cerr << "input number count";
in >> number_count;
Input inn;
inn.numbers.resize(number_count);
for (size_t i = 0; i < number_count; i++) {
in >> inn.numbers[i];
}
size_t bin_count;
in >> inn.bin_count;
return inn;
}
else{
cout << "input number count";
in >> number_count;
Input inn;
inn.numbers.resize(number_count);
for (size_t i = 0; i < number_count; i++) {
in >> inn.numbers[i];
}
size_t bin_count;
in >> inn.bin_count;
return inn;
cin >> number_count;
Input in;
in.numbers.resize(number_count);
for (size_t i = 0; i < number_count; i++) {
cin >> in.numbers[i];
}
size_t bin_count;
cin >> in.bin_count;
return in;
}
int main(int argc, char* argv[]) {
if (argc>1){
CURL *curl = curl_easy_init();
if(curl) {
CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
res = curl_easy_perform(curl);
if (res!=CURLE_OK){
cerr << curl_easy_strerror(res);
exit(1);
}
curl_easy_cleanup(curl);
return 0;
}
}
auto in = input_data(cin, true);
auto bins = make_histogram(in.numbers, in.bin_count);
show_histogram_svg(bins);
return 0;
int main()
{
auto in = input_data();
auto bins = make_histogram(in.numbers, in.bin_count);
show_histogram_text(bins);
return 0;
}

@ -31,25 +31,8 @@
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
<Add directory="curl/include" />
</Compiler>
<Linker>
<Add library="libcurl.dll.a" />
<Add directory="curl/lib" />
</Linker>
<Unit filename="histogram.cpp" />
<Unit filename="histogram.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="main.cpp" />
<Unit filename="svg.cpp" />
<Unit filename="svg.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="text.cpp" />
<Unit filename="text.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>

@ -22,14 +22,14 @@ svg_end() {
}
void
svg_text(double TEXT_LEFT, double BASELINE, string text, size_t bukva_scale) {
cout << "<text x='" << TEXT_LEFT << "' font-size = '" << bukva_scale << "' y='"<< BASELINE <<"'> " << text << "</text>";
svg_text(double TEXT_LEFT, double BASELINE, string text) {
cout << "<text x='" << TEXT_LEFT << "' y='"<< BASELINE <<"'> " << text << "</text>";
}
void svg_rect(double TEXT_WIDTH, double top, double bin_width, double BIN_HEIGHT, string grad){
cout << "<rect x='"<<TEXT_WIDTH<<"' y='"<<top<<"' width='"<<bin_width<<"' height='"<<BIN_HEIGHT<<"' stroke ='cyan' fill='#"<<grad<<grad<<grad<<"' />\n";
void svg_rect(double TEXT_WIDTH, double top, double bin_width, double BIN_HEIGHT){
cout << "<rect x='"<<TEXT_WIDTH<<"' y='"<<top<<"' width='"<<bin_width<<"' height='"<<BIN_HEIGHT<<"' stroke ='cyan' fill='#fce166' />\n";
}
void
@ -43,11 +43,8 @@ show_histogram_svg(const vector<size_t>& bins) {
const auto BLOCK_WIDTH = 10;
const double SCALE = IMAGE_WIDTH - TEXT_WIDTH;
size_t grad = 0;
double max_count = 0;
size_t bukva_scale = 12;
cin >> bukva_scale;
for (double x: bins) {
if (x > max_count) {
max_count = x;
@ -59,9 +56,8 @@ show_histogram_svg(const vector<size_t>& bins) {
double top = 0;
for (size_t i = 0; i < bins.size(); i++) {
const double bin_width = SCALE * ( bins[i] / max_count);
grad = (11 - (bins[i] * 9) / max_count);
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i]), bukva_scale);
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT, to_string(grad));
svg_text(TEXT_LEFT, top + TEXT_BASELINE, to_string(bins[i]));
svg_rect(TEXT_WIDTH, top, bin_width, BIN_HEIGHT);
top += BIN_HEIGHT;
cout << endl;
cout << bin_width;

@ -31,12 +31,6 @@
<Compiler>
<Add option="-Wall" />
</Compiler>
<Unit filename="doctest.h" />
<Unit filename="histogram.cpp" />
<Unit filename="histogram_internal.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="unittest.cpp" />
<Extensions>
<lib_finder disable_auto="1" />
</Extensions>

@ -6,19 +6,17 @@
TEST_CASE("distinct positive numbers") {
double min = 0;
double max = 0;
std::vector<double>test = {0};
bool flag;
find_minmax({1, 2}, min, max);
CHECK(min == 1);
CHECK(max == 2);
}
TEST_CASE("distinct negative numbers") {
double min = 0;
double max = 0;
find_minmax({-1, -2, -3, -4, -5}, min, max);
CHECK(min == -5);
CHECK(max == -1);
}
TEST_CASE("distinct null vector") {
double min = 0;
double max = 0;
CHECK(!find_minmax({}, min, max));
}
CHECK(true);
}

Загрузка…
Отмена
Сохранить