Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <locale>
- #include <string>
- #include <vector>
- using namespace std;
- int main() {
- setlocale(LC_ALL, "Russian");
- string s;
- vector<string> v;
- int len = 0;
- cout << "Введите строку: " << endl;
- cin >> s;
- for (int i = 0; i < s.size(); ++i) {
- if (s[i] % 2 == 0) {
- ++len;
- }
- else {
- if (len > 2) {
- v.push_back(s.substr(i - len, len));
- }
- len = 0;
- }
- }
- if (len > 2) {
- v.push_back(s.substr(s.size() - len, len));
- }
- if (v.empty()) {
- cout << "Подстроки с символами четного кода длины больше 2 не найдены." << endl;
- }
- else {
- cout << "Подстроки символов с четным кодом длины больше 2:" << endl;
- for (string& substr : v) {
- cout << substr << endl;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement