Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////
- Delete_end()
- {
- Node *temp = NULL;
- Node *head2 = head;
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- while (head2->ptr != NULL) { // перемотка на последние указатели
- temp = head2;
- head2 = head2->ptr;
- }
- if (temp) {
- //<udalenie poslednego>
- temp->ptr = NULL;
- delete head2;
- //< /udalenie poslednego>
- }
- }
- ////////////////
- Delete_prev_end()
- {
- Node *temp = NULL;
- Node *head2 = head;
- Node *t = head;
- Node *t2 = head;
- Node *t3 = head;
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- if (head2->ptr == NULL) { return NULL; } // В списке нет узлов по условию
- if (head2->ptr->ptr == NULL) { return NULL; } // В списке нет узлов
- int j = 0;
- cout << head2->FirstName << " - " << head2 << " - " << endl;
- while (head2->ptr != NULL) {j++;
- head2 = head2->ptr;
- temp = head2;
- t = temp->ptr;
- t3 = t->ptr;
- if (head2->ptr->ptr->ptr == NULL) {
- //// <operation>
- temp->ptr = t3; delete t;
- //// </operation>
- return NULL;
- }
- }
- }
- ///////////////////
- ////////////////
- head_del()
- {
- Node *temp = NULL;
- Node *head2 = head;
- Node *t = head;
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- //<operation>
- head = head2->ptr;
- t = NULL;
- delete t;
- //</operation>
- }
- ////////////////
- ////////////////
- head_next_del()
- {
- Node *t1 = NULL;
- Node *head2 = head;
- Node *t2 = head;
- Node *t3 = head;
- t1 = head;
- t2 = t1->ptr;
- t3 = t2->ptr;
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- // <operation>
- t1->ptr = t3;
- t2->ptr = NULL;
- delete t2;
- // </operation>
- }
- ////////////////
- ////////////////
- Dobav_head()
- {
- string value;
- Node *temp = NULL;
- Node *head2 = head;
- cin >> value;
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- //<opation>
- Node *elem2 = new Node();
- elem2->FirstName = value;
- elem2->ptr = head2;
- head = elem2;
- //</opation>
- }
- ////////////////
- Dobav_head_next()
- {
- Node *t1 = NULL;
- Node *t2 = head;
- t1 = head;
- t2 = t2->ptr;
- if (t2 == NULL) { return NULL; } // В списке нет узлов
- //<operation>
- Node *elem2 = new Node();
- elem2->FirstName = "88";
- t1->ptr = elem2;
- elem2->ptr = t2;
- //<operation>
- }
- ////////////////
- ////////////////
- Dobav_n_last()
- {
- string value = "88"
- Node *temp = NULL;
- Node *head2 = head;
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- while (head2->ptr != NULL) {
- temp = head2;
- head2 = head2->ptr;
- }
- // <operation>
- Node *elem2 = new Node();
- elem2->FirstName = value;
- elem2->ptr = NULL;
- head2->ptr = elem2;
- // </operation>
- }
- ////////////////
- /////////////////
- Dobav_pre_last()
- {
- Node *temp = NULL;
- Node *t = head;
- Node *head2 = head;
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- while (head2->ptr != NULL) {
- head2 = head2->ptr;
- t = t->ptr;
- if (t->ptr->ptr == NULL) {
- temp = t->ptr;
- //<operation>
- Node *elem2 = new Node();
- elem2->FirstName = "88";
- t->ptr = elem2;
- elem2->ptr = temp;
- //</operation>
- return NULL;
- }
- }
- }
- ////////////////
- //chtenie
- reedOfFile(string nameFile)
- {
- ifstream inf(nameFile);
- // Если мы не можем открыть файл для чтения его содержимого,
- if (!inf)
- {
- // то выводим следующее сообщение об ошибке и выполняем функцию exit()
- cerr << "SetText.txt could not be opened for reading!" << endl;
- exit(1);
- }
- string strInput2;
- // Пока есть, что читать,
- while (inf)
- {
- // то перемещаем то, что можем прочитать, в строку, а затем выводим эту строку на экран
- string strInput;
- getline(inf, strInput);
- strInput2 = strInput2 + strInput;
- }
- return strInput2;
- //cout << strInput2 << endl;
- }
- ///////////////////
- // Zapis
- {
- using namespace std;
- ofstream outf("SetText.txt");
- if (!outf)
- {
- cerr << "SetText.txt could not be opened for writing!" << endl;
- exit(1);
- }
- for (i = 0; i < N; i++) {
- outf << fly[i].punkt << " " << fly[i].numb << " " << fly[i].type << endl;
- }
- }
- ////////////////
- Node* List::By_value_del()
- {
- Node *temp = NULL;
- Node *head2 = head;
- Node *t = head;
- Node *t2 = head;
- Node *t3 = head;
- Node *t4 = head;
- Node *tail = head;
- string value_del = "31";
- cin >> value_del;
- while (tail->ptr != NULL) {
- tail = tail->ptr;
- }
- if (head2 == NULL) { return NULL; } // В списке нет узлов
- else if (head2->FirstName == value_del) { // kluch v golove
- head_del();
- }
- else if (tail->FirstName == value_del) { // kluch v hvoste
- Delete_end();
- }
- else {
- int j = 0;
- while (head2 != NULL) {
- temp = head2;
- t = temp->ptr;
- if (t->FirstName == value_del) {
- t3 = t->ptr;
- //// <operation>
- temp->ptr = t3; delete t;
- //// </operation>
- break;
- }
- head2 = head2->ptr;
- j++;
- }
- }
- }
- ///////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement