diff --git a/Lesson_2/Task_4/main.cpp b/Lesson_2/Task_4/main.cpp index a81d275..c41af8e 100644 --- a/Lesson_2/Task_4/main.cpp +++ b/Lesson_2/Task_4/main.cpp @@ -10,10 +10,10 @@ int main() int words = 1; for (int character = 0; character < 256; ++character) { - if (str[character] == ' ') - ++words; - else if (str[character] == 0) + if (str[character] == 0) break; + else if (str[character] < 'A' || str[character] > 'z') + ++words; } cout << "Number of words: " << words << endl;