Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int n;
- cout << "Введите размер всех строк: ";
- cin >> n;
- cin.ignore();
- char *str = new char[n];
- cout << "Введите строку: ";
- gets_s(str, n - 1);
- char *strp = new char[n];
- cout << "Введите подстроку: ";
- gets_s(strp, n - 1);
- while (true)
- {
- char *q = strstr(str, strp);
- if (q != NULL)
- {
- char *qp = q + strlen(strp);
- strcpy_s(q, n/2, qp);
- }
- else break;
- }
- cout << "Результат удаления подстроки из строки: " << str << endl;
- char *a = new char[n * 2];
- for (int i = 0; i < n * 2; i++)
- {
- a[i] = 0;
- }
- for (int i = 0, j = 0; i < strlen(str); i++)
- {
- a[j++] = str[i];
- if (str[i] == 'a')
- {
- a[j++] = ' ';
- }
- }
- cout << "Результат добавления пробелов после a: " << a << endl;
- char l[300] = { 0 };
- cout << "Введите еще одну строку для проверки на буквы: " << endl;
- gets_s(l, 299);
- int y = 0;
- int i = 0;
- while (l[y])
- {
- if (isalpha(l[y]))
- {
- i++;
- }
- y++;
- }
- if (y == i)
- {
- cout << "Вся строка состоит из букв" << endl;
- }
- else
- {
- cout << "Не все символы строки являются буквами" << endl;
- }
- delete[] a;
- delete[] str;
- delete[] strp;
- system("PAUSE");
- return 0;
- }
Add Comment
Please, Sign In to add comment