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

..

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

1
.gitignore поставляемый

@ -1,2 +1,3 @@
/bin /bin
/obj /obj
/layout

@ -2,107 +2,9 @@
#include <vector> #include <vector>
using namespace std; using namespace std;
struct Input{
vector<double> numbers;
size_t bin_count{};
};
Input input_data(){
Input in;
size_t number_count;
cerr << "Enter number count: ";
cin >> number_count;
in.numbers.resize(number_count);
vector<double> numbers(number_count);
for (size_t i = 0; i < number_count; i++) {
cin >> in.numbers[i];
}
size_t bin_count;
cerr << "Enter bin count";
cin >> in.bin_count;
return in;
}
void find_minmax(vector<double>& numbers, double& min,double& max){
min = numbers[0];
max = numbers[0];
for (double x : numbers)
{
if (x < min)
{
min = x;
}
else if (x > max)
{
max = x;
}
}
}
vector<double> make_histogram(vector<double>& numbers, size_t bin_count){
double min, max;
size_t number_count = size(numbers);
vector<double> bins(bin_count));
find_minmax(numbers, min, max);
double bin_size = (max-min)/bin_count;
for (size_t i = 0; i < number_count; i++)
{
bool found = false;
for (size_t j = 0; (j < bin_count - 1) && !found; j++)
{
auto lo = min + j * bin_size;
auto hi = min + (j + 1) * bin_size;
if ((lo <= numbers[i]) && (numbers[i] < hi))
{
bins[j]++;
found = true;
}
}
if (!found)
{
bins[bin_count - 1]++;
}
}
return bins;
}
void show_histogram_text(vector<double>& bins){
int maxbin = 0;
for(int bin : bins){
if(bin > maxbin){
maxbin = bin;
}
}
for(int bin : bins)
{
size_t height = bin;
if (maxbin > 76){
size_t height = 76 * (static_cast<double>(bin) / maxbin);
}
if(10<=bin && bin<100){
cout << " " << bin << "|";
}
else if(bin<10){
cout << " " << " " << bin << "|";
}
else if(bin>100){
cout << bin << "|";
}
for(int i = 0; i < height; i++)
{
cout << "*";
}
cout << endl;
}
return 0;
}
}
int main() int main()
{ {
auto in = input_data();
auto bins = make_histogram(in.numbers, in.bin_count);
show_histogram_text(bins, ...);
double min, max;
find_minmax(in.numbers, min, max);
const size_t SCREEN_WIDTH = 80; const size_t SCREEN_WIDTH = 80;
const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1; const size_t MAX_ASTERISK = SCREEN_WIDTH - 3 - 1;
size_t number_count, bin_count; size_t number_count, bin_count;

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