code: добавлена проверка ввода
Этот коммит содержится в:
19
main.cpp
19
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()
|
||||
|
||||
Ссылка в новой задаче
Block a user