Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Windows.h>
- #include <iostream>
- #include <conio.h>
- #include <cstdio>
- #include <cstring>
- #include "operations_str.h"
- using namespace std;
- int main()
- {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- int choice = 0;
- cout << endl << " Введите строку: " << endl;
- char* str1 = read_str();
- //интерфейс
- do {
- cout << endl << " Выберите действие: " << endl;
- cout << " 1. Определение длины; " << endl;
- cout << " 2. Конкатенация (слияние строк); " << endl;
- cout << " 3. Поиск подстроки; " << endl;
- cout << " 4. Удаление подстроки; " << endl;
- cout << " 5. Копирование подстроки; " << endl;
- cout << " 6. Выход. " << endl;
- choice = correct_input();
- cout << endl;
- if (choice >= 1 || choice < 6)
- {
- if (choice == 1)
- cout << "Длина строки: " << my_strlen(str1) << "." << endl;
- if (choice == 2)
- {
- cout << endl << " Введите подстроку: " << endl;
- char* str2 = read_str();
- cout << " Конкатенация (слияние строк): " << my_strcat(str1, str2) << "." << endl;
- }
- if (choice == 3)
- {
- cout << endl << " Введите подстроку: " << endl;
- char* str2 = read_str();
- int result = whereis(str1, str2);
- if (result >= 0)
- cout << " Поиск подстроки: " << whereis(str1, str2) << endl;
- else cout << " Поиск подстроки: данная подстрока не найдена." << endl;
- delete[] str2;
- }
- if (choice == 4)
- {
- cout << endl << " Введите подстроку: " << endl;
- char* str2 = read_str();
- cout << " Удаление подстроки: " << again_subs(str1, str2) << endl;
- delete[] str2;
- }
- if (choice == 5)
- {
- int length = 0;
- cout << " Введите необходимое число символов, которые нужно скопировать: " << endl;
- cin >> length;
- cout << " Копирование подстроки: " << substring(str1, length) << endl;
- }
- if (choice == 6)
- return 0;
- }
- if (choice > 6 || choice < 1)
- cout << " Неправильный ввод, попробуйте еще раз." << endl;
- } while (choice != 6);
- delete[] str1;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement