From d0b5fddd3508eefcd918b99f08a8a9879d33afd5 Mon Sep 17 00:00:00 2001 From: LatyshevGI Date: Thu, 22 May 2025 21:33:00 +0300 Subject: [PATCH] =?UTF-8?q?code;=20cin=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BD=D0=B0=20in?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 ++- lab01.cbp | 7 +++++-- main.cpp | 18 +++++++++--------- unittest.cbp | 4 ++++ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index e7910eb..95c1f92 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ /obj /lab01.depend /lab01.layout -/main.exe /main.o +/main.exe +/unittest.layout diff --git a/lab01.cbp b/lab01.cbp index cc05dde..2b92edc 100644 --- a/lab01.cbp +++ b/lab01.cbp @@ -33,9 +33,12 @@ - - + + + + + diff --git a/main.cpp b/main.cpp index 558fb56..0672980 100644 --- a/main.cpp +++ b/main.cpp @@ -6,23 +6,23 @@ struct Input { vector vec; size_t korz{}; }; -Input input_data() { - Input in; + +Input input_data(istream& in) { + Input lin; size_t n, korz; cerr << "Number of elements: "; - cin >> n; - in.vec.resize(n); - cerr << "Elements: "; + in >> n; + lin.vec.resize(n); for (size_t i = 0; i < n; i++) - cin >> in.vec[i]; + in >> lin.vec[i]; cerr << "Enter bin count: "; - cin >> in.korz; - return in; + in >> lin.korz; + return lin; } int main() { - auto in = input_data(); + auto in = input_data(cin); auto bins = make_histogram(in.korz, in.vec); show_histogram_svg(bins); } diff --git a/unittest.cbp b/unittest.cbp index 6da4486..379d0a2 100644 --- a/unittest.cbp +++ b/unittest.cbp @@ -31,6 +31,10 @@ + + + +