From 05250ed596c9643adba2ef030d49852c4f016b08 Mon Sep 17 00:00:00 2001
From: RybakovaSA <RybakovaSA@mpei.ru>
Date: Thu, 22 May 2025 22:21:22 +0300
Subject: [PATCH] =?UTF-8?q?code:=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?=
 =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20main?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 main.cpp | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/main.cpp b/main.cpp
index ee10b94..3b155d7 100644
--- a/main.cpp
+++ b/main.cpp
@@ -2,7 +2,7 @@
 #include <iostream>
 #include "histogram.h"
 #include "text.h"
-#include "svg.h"  
+#include "svg.h"
 using namespace std;
 
 struct Input {
@@ -10,29 +10,36 @@ struct Input {
     size_t bin_count{};
 };
 
-Input input_data() {
+Input input_data(istream& in_stream, bool prompt) {
     Input in;
     size_t number_count;
     
-    cerr << "Enter number count: ";
-    cin >> number_count;
+    if (prompt) {
+        cerr << "Enter number count: ";
+    }
+    in_stream >> number_count;
     
     in.numbers.resize(number_count);
-    cerr << "Enter numbers: ";
+    if (prompt && number_count > 0) {
+        cerr << "Enter numbers: ";
+    }
     for (size_t i = 0; i < number_count; i++) {
-        cin >> in.numbers[i];
+        in_stream >> in.numbers[i];
     }
     
-    cerr << "Enter bin count: ";
-    cin >> in.bin_count;
+    if (prompt) {
+        cerr << "Enter bin count: ";
+    }
+    in_stream >> in.bin_count;
     
     return in;
 }
 
 int main() {
-    auto in = input_data();
+    auto in = input_data(cin, true);  // true - выводить подсказки
     auto bins = make_histogram(in.numbers, in.bin_count);
     show_histogram_svg(bins);
     
     return 0;
 }
+}