Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- using namespace std;
- Dictionary* deletingWords(Dictionary *dict, int &emptyArr)
- {
- system("cls");
- print(dict, emptyArr,0);
- if (emptyArr > 0)
- {
- char word[31];
- cout << "Введите слово, которое хотите удалить: ";
- cin >> word;
- bool flag = false;
- for (int i = 0; i < emptyArr; i++)
- {
- if (simular(dict[i].engl, word))
- {
- flag = true;
- for (int j = 0; j < length(dict[i].engl); j++)
- dict[i].engl[j] = 'z';
- break;
- }
- }
- if (flag)
- {
- sort(dict, emptyArr);
- Dictionary *temp;
- if (emptyArr == 1)
- {
- temp = new Dictionary[1];
- temp[0].engl = new char[2];
- temp[0].engl[0] = ' ';
- temp[0].engl[1] = '\0';
- temp[0].rus = new char[2];
- temp[0].rus[0] = ' ';
- temp[0].rus[1] = '\0';
- delete[] dict;
- dict = temp;
- emptyArr--;
- temp = nullptr;
- }
- else
- {
- temp = new Dictionary[emptyArr - 1];
- for (int i = 0; i < emptyArr - 1; i++)
- {
- temp[i].engl = new char[length(dict[i].engl) + 1];
- for (int j = 0; j < length(dict[i].engl); j++)
- {
- temp[i].engl[j] = dict[i].engl[j];
- }
- temp[i].engl[length(dict[i].engl)] = '\0';
- temp[i].rus = new char[length(dict[i].rus) + 1];
- for (int j = 0; j < length(dict[i].rus); j++)
- {
- temp[i].rus[j] = dict[i].rus[j];
- }
- temp[i].rus[length(dict[i].rus)] = '\0';
- }
- delete[] dict;
- emptyArr--;
- dict = temp;
- temp = nullptr;
- }
- }
- else cout << "Слово для удаления не было найдено!" << endl;
- }
- else cout << "Словарь пуст" << endl;
- return dict;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement