diff options
author | Samuel Fadel <samuel@nihil.ws> | 2018-07-25 16:45:38 -0300 |
---|---|---|
committer | Samuel Fadel <samuel@nihil.ws> | 2018-07-25 16:45:38 -0300 |
commit | 86c9f2966dd93b9bc17c48c88d2faa92cd94b771 (patch) | |
tree | 33058af39c7b52bdf9f5f6c9f98ad6418c0c112d /src | |
parent | 3b12fea57f9cdae45bf8801dd274eb3669530e1c (diff) |
Simpler output impl.
sparkify() now receives generic ostream as argument; pass std::cout as
arg to sparkify() in main.
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 95b9140..8291db2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,6 @@ #include <algorithm> #include <iostream> #include <iterator> -#include <sstream> #include <vector> const char *TICKS[] = {"▁", "▂", "▃", "▄", "▅", "▆", "▇", "█"}; @@ -10,7 +9,7 @@ const size_t NUM_TICKS = 8; const double EPSILON = 1e-8; template<typename T> -void sparkify(const std::vector<T> &values, std::ostringstream &out) { +void sparkify(const std::vector<T> &values, std::ostream &out) { auto minmax = std::minmax_element(values.begin(), values.end()); auto min = *minmax.first, max = *minmax.second; @@ -30,7 +29,6 @@ void sparkify(const std::vector<T> &values, std::ostringstream &out) { int main() { std::vector<double> values; - std::ostringstream out; for (double value; std::cin >> value;) { values.push_back(value); } @@ -42,7 +40,7 @@ int main() return 0; } - sparkify(values, out); - std::cout << out.str() << std::endl; + sparkify(values, std::cout); + std::cout << std::endl; return 0; } |