#include <iostream> #include <string> #include <windows.h> using namespace std; int main() { SetConsoleCP(1251); SetConsoleOutputCP(1251); unsigned count{}; // счетчик, указывающий колличество определенного символа в фамилии string sname; cout << "Введите вашу фамилию: "; getline(cin, sname); for (const char k : sname) { if (k == 'б' or k == 'Б') { count++; } } cout << "Количество вхождений буквы: " << count << endl; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter