code: My Variant
Этот коммит содержится в:
4
main.cpp
4
main.cpp
@@ -26,7 +26,6 @@ int main()
|
|||||||
{
|
{
|
||||||
auto in = input_data();
|
auto in = input_data();
|
||||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||||
//show_histogram_text(bins,in.bin_count,in.numbers);
|
|
||||||
auto max_count=bins[0];
|
auto max_count=bins[0];
|
||||||
for(size_t x : bins){
|
for(size_t x : bins){
|
||||||
if (x > max_count)
|
if (x > max_count)
|
||||||
@@ -34,6 +33,7 @@ int main()
|
|||||||
max_count=x;
|
max_count=x;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
show_histogram_svg(bins, max_count);
|
show_histogram_text(bins,in.bin_count,in.numbers,max_count);
|
||||||
|
//show_histogram_svg(bins, max_count);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
17
text.cpp
17
text.cpp
@@ -7,25 +7,34 @@ using namespace std;
|
|||||||
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;
|
||||||
|
|
||||||
void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const std::vector<double> numbers)
|
void show_histogram_text(const std::vector<size_t> bins, size_t bin_count, const std::vector<double> numbers,size_t max_count)
|
||||||
{
|
{
|
||||||
size_t procent=100;
|
size_t procent=100;
|
||||||
for(size_t i = 0;i<(bin_count-1);i++){
|
for(size_t i = 0;i<(bin_count-1);i++){
|
||||||
double number = numbers.size();
|
double number = numbers.size();
|
||||||
//cout<<number;
|
|
||||||
double proc=(bins[i]/number)*100;
|
double proc=(bins[i]/number)*100;
|
||||||
procent -=round(proc);
|
procent -=round(proc);
|
||||||
printf("%3.0f%%:", proc);
|
printf("%3d:", bins[i]);
|
||||||
for(size_t j = 0;j<bins[i];j++)
|
for(size_t j = 0;j<bins[i];j++)
|
||||||
{
|
{
|
||||||
cout<<"*";
|
cout<<"*";
|
||||||
}
|
}
|
||||||
|
for(size_t g=0;g<(max_count-bins[i]);g++)
|
||||||
|
{
|
||||||
|
cout<<" ";
|
||||||
|
}
|
||||||
|
printf("%3.0f%%",proc);
|
||||||
cout<<endl;
|
cout<<endl;
|
||||||
}
|
}
|
||||||
//procent=Math.round(procent);
|
//procent=Math.round(procent);
|
||||||
printf("%3d%%:",procent);
|
printf("%3d:",bins[bin_count-1]);
|
||||||
for(size_t j = 0;j<bins[bin_count - 1];j++)
|
for(size_t j = 0;j<bins[bin_count - 1];j++)
|
||||||
{
|
{
|
||||||
cout<<"*";
|
cout<<"*";
|
||||||
}
|
}
|
||||||
|
for(size_t g=0;g<(max_count-bins[bin_count-1]);g++)
|
||||||
|
{
|
||||||
|
cout<<" ";
|
||||||
|
}
|
||||||
|
printf("%3d%%",procent);
|
||||||
}
|
}
|
||||||
|
|||||||
2
text.h
2
text.h
@@ -5,6 +5,6 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
void
|
void
|
||||||
show_histogram_text(const std::vector<size_t> bins, size_t bin_count,const std::vector<double> numbers);
|
show_histogram_text(const std::vector<size_t> bins, size_t bin_count,const std::vector<double> numbers,size_t max_count);
|
||||||
|
|
||||||
#endif // TEXT_H_INCLUDED
|
#endif // TEXT_H_INCLUDED
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user