Advertisement
Lavig

Лабораторна робота №13 (Завдання 2)

Nov 29th, 2024
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     SetConsoleOutputCP(1251);
  9.     const int MAX = 100;
  10.     int count{}, i{}, length{};
  11.     char sentence[MAX]{};
  12.     cout << "Введіть будь-яке речення: ";
  13.     cin.getline(sentence, MAX, '\n');
  14.     length = strlen(sentence);
  15.     for (i = length - 1; i >= 0; i--) {
  16.         if (sentence[i] == ' ') {
  17.             break;
  18.         }
  19.         if (sentence[i] == 'k') {
  20.             count++;
  21.         }
  22.     }
  23.     cout << "Кількість букв k в останньому слові масиву - " << count;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement