code: добавлена проверка ввода
Этот коммит содержится в:
19
main.cpp
19
main.cpp
@@ -14,8 +14,10 @@ struct Input {
|
|||||||
Input
|
Input
|
||||||
input_data() {
|
input_data() {
|
||||||
int i;
|
int i;
|
||||||
string check(" ");
|
|
||||||
size_t number_count;
|
size_t number_count;
|
||||||
|
string check1 = " ";
|
||||||
|
string check2 = "#";
|
||||||
|
|
||||||
cerr << "Enter number count: ";
|
cerr << "Enter number count: ";
|
||||||
cin >> number_count;
|
cin >> number_count;
|
||||||
|
|
||||||
@@ -31,9 +33,20 @@ input_data() {
|
|||||||
|
|
||||||
|
|
||||||
cerr << "Enter stroke colour without spaces or in code format:";
|
cerr << "Enter stroke colour without spaces or in code format:";
|
||||||
cin >> in.stroke;
|
cin.ignore();
|
||||||
return in;
|
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()
|
int main()
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user