From 3fcab8541d103a818c281f0d00928a28f3447d8d Mon Sep 17 00:00:00 2001 From: Stanislav Mykhailenko Date: Thu, 18 Jul 2024 14:19:09 +0300 Subject: [PATCH] Fix Lesson 2 Task 4 --- Lesson_2/Task_4/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;