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

...

4 Коммитов

Разница между файлами не показана из-за своего большого размера Загрузить разницу

@ -32,7 +32,22 @@
<Add option="-Wall" /> <Add option="-Wall" />
<Add option="-fexceptions" /> <Add option="-fexceptions" />
</Compiler> </Compiler>
<Unit filename="histogram.cpp" />
<Unit filename="histogram.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="histogram_internal.h">
<Option target="&lt;{~None~}&gt;" />
</Unit>
<Unit filename="main.cpp" /> <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> <Extensions>
<lib_finder disable_auto="1" /> <lib_finder disable_auto="1" />
</Extensions> </Extensions>

@ -1,102 +1,50 @@
#include <iostream> #include "histogram.h"
#include <vector> #include "svg.h"
using namespace std; using namespace std;
int main() struct Input {
{ vector<double> numbers;
size_t numbers, columns, count; size_t bin_count{};
float minn, maxx, diff, lo, hi; };
cerr << "Quantity of numbers = "; cin >> numbers;
vector<float> xs(numbers);
cerr << "Enter your numbers: ";
for (int i = 0; i < numbers; ++i)
{
cin >> xs[i];
}
cerr << "Columns = "; cin >> columns;
vector<size_t> a(columns);
maxx = xs[0];
minn = xs[0];
for (int i = 0; i < numbers; i++)
{
if (xs[i] > maxx)
maxx = xs[i];
else
{
if (xs[i] < minn)
minn = xs[i];
}
}
diff = (maxx - minn) / columns;
lo = minn;
size_t max_count = 0; Input
for (int i = 0; i < columns; ++i) input_data(istream& inn, bool prompt)
{ {
count = 0; size_t number_count;
if (prompt == true)
if (i != columns - 1) cerr << "number_count = ";
{ inn >> number_count;
hi = lo + diff;
} Input in;
else in.numbers.resize(number_count);
{
hi = maxx; if (prompt == true)
} cerr << "numbers:";
for (int j = 0; j < numbers; j++) for (size_t i = 0; i < number_count; i++) {
{ inn >> in.numbers[i];
if (i == 0)
{
if ((xs[j] >= lo) && (xs[j] <= hi))
count++;
}
else
{
if ((xs[j] > lo) && (xs[j] <= hi))
count++;
}
}
a[i] = count;
lo = hi;
if (max_count < a[i])
max_count = a[i];
} }
const size_t SCREEN_WIDTH = 80; cerr << "columns = ";
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; cin >> in.bin_count;
size_t height; return in;
for (int i = 0; i < columns; i++) }
{
if (a[i] == 0)
continue;
if (a[i] < 10) int
cout << " "; main(int argc, char* argv[])
else {
if (a[i] < 100) if (argc > 1)
cout << " "; {
cerr << argc;
for(int i = 0; i < argc; i++){
cerr << "argv[" << i << "] = " << argv[i];
}
return 0;
}
cout << a[i] << "|"; auto in = input_data(cin, true);
if (max_count > MAX_ASTERISK) auto bins = make_histogram(in.numbers, in.bin_count);
height = MAX_ASTERISK * (static_cast<double>(a[i]) / max_count);
else
height = a[i];
for (int j = 0; j < height; j++) show_histogram_svg(bins);
{
cout << "*";
}
cout << endl;
}
} }

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