Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <algorithm>
- #include <Windows.h>
- using namespace std;
- class Lettercount {
- private:
- string str;
- public:
- Lettercount() {};
- Lettercount(string stroka) : str(stroka) {};
- int count() {
- int letter_count = 0;
- string str_cop(str);
- transform(str_cop.begin(), str_cop.end(), str_cop.begin(), ::toupper);
- for (int i = 0; i < str_cop.length(); i++) {
- if (isalpha(str_cop[i])) {
- letter_count++;
- }
- if ((int(str_cop[i]) >= 'А' && int(str_cop[i]) <= 'Я') || (int(str_cop[i]) == 'Ё'))
- {
- letter_count++;
- }
- }
- return letter_count;
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- string your_stroka;
- cout << "Enter the string: ";
- cin >> your_stroka;
- Lettercount obj(your_stroka);
- cout << "Your result: " << obj.count();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement