#include #include #include #include #include #include const std::array TICKS = {"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"}; const double EPSILON = 1e-8; template void sparkify(InputIterator first, InputIterator last, OutputIterator &out) { auto minmax = std::minmax_element(first, last); auto min = *minmax.first, max = *minmax.second; auto values_range = max - min; if (values_range < EPSILON) { std::fill_n(out, last - first, TICKS[0]); } else { auto coef = (TICKS.size() - 1) / values_range; std::transform(first, last, out, [&](auto x) { return TICKS[(size_t) round((x - min) * coef)]; }); } } int main() { std::istream_iterator cin_it(std::cin), eos; std::vector values(cin_it, eos); if (!std::cin.eof() && std::cin.fail()) { std::cerr << "Parse error" << std::endl; return 1; } if (values.empty()) { return 0; } std::ostream_iterator cout_it(std::cout); sparkify(values.begin(), values.end(), cout_it); std::cout << std::endl; return 0; }