From ba1a4fac86bc7fb95ad0b4e628f02741d3d8a2cf Mon Sep 17 00:00:00 2001 From: SavinSA Date: Mon, 29 Apr 2024 13:22:21 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B0=20=D0=B2=D0=B2=D0=BE=D0=B4=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/main.cpp b/main.cpp index d6f810d..fe6fb0d 100644 --- a/main.cpp +++ b/main.cpp @@ -14,8 +14,10 @@ struct Input { Input input_data() { int i; - string check(" "); size_t number_count; + string check1 = " "; + string check2 = "#"; + cerr << "Enter number count: "; cin >> number_count; @@ -31,9 +33,20 @@ input_data() { cerr << "Enter stroke colour without spaces or in code format:"; - cin >> in.stroke; - return in; + cin.ignore(); + getline(cin, in.stroke); + for (i = 0; i < in.stroke.length(); i++) { + if (isspace(in.stroke[i])) { + cerr << "invalid input"; + } + } + if (in.stroke[0] == check2[0]) { + if (in.stroke.length() != 7) { + cerr << "invalid input"; + } + } + return in; } int main()