Advertisement
anansie

основной

Jun 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.39 KB | None | 0 0
  1. #include <Windows.h>
  2. #include <iostream>
  3. #include <conio.h>
  4. #include <cstdio>
  5. #include <cstring>
  6. #include "operations_str.h"
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     SetConsoleCP(1251);
  12.     SetConsoleOutputCP(1251);
  13.     int choice = 0;
  14.     cout << endl << " Введите строку: " << endl;
  15.  
  16.     char* str1 = read_str();
  17.    
  18.     //интерфейс
  19.  
  20.     do {
  21.         cout << endl << " Выберите действие: " << endl;
  22.         cout << " 1. Определение длины; " << endl;
  23.         cout << " 2. Конкатенация (слияние строк); " << endl;
  24.         cout << " 3. Поиск подстроки; " << endl;
  25.         cout << " 4. Удаление подстроки; " << endl;
  26.         cout << " 5. Копирование подстроки; " << endl;
  27.         cout << " 6. Выход. " << endl;
  28.         choice = correct_input();
  29.         cout << endl;
  30.  
  31.         if (choice >= 1 || choice < 6)
  32.         {
  33.             if (choice == 1)
  34.                 cout << "Длина строки: " << my_strlen(str1) << "." << endl;
  35.  
  36.             if (choice == 2)
  37.             {
  38.                 cout << endl << " Введите подстроку: " << endl;
  39.                 char* str2 = read_str();
  40.                 cout << " Конкатенация (слияние строк): " << my_strcat(str1, str2) << "." << endl;
  41.  
  42.             }
  43.             if (choice == 3)
  44.             {
  45.                 cout << endl << " Введите подстроку: " << endl;
  46.                 char* str2 = read_str();
  47.                 int result = whereis(str1, str2);
  48.                 if (result >= 0)
  49.                     cout << " Поиск подстроки: " << whereis(str1, str2) << endl;
  50.                 else cout << " Поиск подстроки: данная подстрока не найдена." << endl;
  51.                 delete[] str2;
  52.             }
  53.             if (choice == 4)
  54.             {
  55.                 cout << endl << " Введите подстроку: " << endl;
  56.                 char* str2 = read_str();
  57.                 cout << " Удаление подстроки: " << again_subs(str1, str2) << endl;
  58.                 delete[] str2;
  59.             }
  60.             if (choice == 5)
  61.             {
  62.                 int length = 0;
  63.                 cout << " Введите необходимое число символов, которые нужно скопировать: " << endl;
  64.                 cin >> length;
  65.                 cout << " Копирование подстроки: " << substring(str1, length) << endl;
  66.             }
  67.             if (choice == 6)
  68.                 return 0;
  69.  
  70.         }
  71.  
  72.         if (choice > 6 || choice < 1)
  73.             cout << " Неправильный ввод, попробуйте еще раз." << endl;
  74.  
  75.     } while (choice != 6);
  76.  
  77.     delete[] str1;
  78.     system("pause");
  79.     return 0;
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement