Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <windows.h>
- #include<iomanip>
- #include<fstream>
- #include <iostream>
- #include <fstream>
- #include <stdlib.h>
- #include <string>
- #include <iomanip>
- #include <conio.h>
- using namespace std;
- struct address
- {
- int home;
- string street;
- int flate;
- };
- struct bank {
- string surn;
- string name;
- string ot;
- int day;
- int month;
- int year;
- char pol;
- struct address ad;
- };
- struct list {
- bank inf;
- list *next;
- list *pre;
- };
- void SetColor(int text, int bg) {
- HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
- SetConsoleTextAttribute(hStdOut, (WORD)((bg << 4) | text));
- }
- list* create()
- {
- system("color 70");
- list *temp = new list;
- cout << "Введите данные для первого элемента в списке\n";
- cout << "\nВведите фамилию\n";
- cin>>temp->inf.surn;
- cout << "\nВведите имя\n";
- cin >> temp->inf.name;
- cout << "\nВведите отчество\n";
- cin >> temp->inf.ot;
- cout << "\nВведите день рождения\n";
- cin >> temp->inf.day;
- if (temp->inf.day > 31 || temp->inf.day < 1)
- {
- cout << "\nТакого числа не существует\n";
- system("pause");
- delete temp;
- return 0;
- }
- cout << "\nВведите месяц рождения\n";
- cin >> temp->inf.month;
- if (temp->inf.month > 12 || temp->inf.day < 1)
- {
- cout << "Введено неверное число\n";
- system("pause");
- delete temp;
- return 0;
- }
- if (temp->inf.month == 2 && temp->inf.day > 29)
- {
- cout << "\nВ феврале на может быть больше 29 дней\n";
- system("pause");
- delete temp;
- return 0;
- }
- else
- {
- if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
- {
- cout << "\nТакой даты не сущетсвует\n";
- system("pause");
- delete temp;
- return 0;
- }
- }
- cout << "\nВведите год рождения\n";
- cin >> temp->inf.year;
- if (temp->inf.year < 1950 || temp->inf.year>5000)
- {
- cout << "\nВведен неверный год\n";
- system("pause");
- delete temp;
- return 0;
- }
- if (temp->inf.month == 2 && temp->inf.year % 4 != 0 && temp->inf.day==29)
- {
- cout << "Увы, это не високосный год\n";
- system("pause");
- delete temp;
- return 0;
- }
- cout << "\nВведите пол\n";
- cout<<"Подсказка:(w/m)\n";
- cin >> temp->inf.pol;
- if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
- {
- cout << "\nВы ввели не верный символ\n";
- system("pause");
- delete temp;
- return 0;
- }
- cout << "\nВведите улицу\n";
- cin >> temp->inf.ad.street;
- cout << "\nВведите номер дома\n" << endl;
- cin >> temp->inf.ad.home;
- if (temp->inf.ad.home<1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- delete temp;
- return 0;
- }
- cout << "\nВведите номер квартиры\n";
- cin >> temp->inf.ad.flate;
- if (temp->inf.ad.flate < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- delete temp;
- return 0;
- }
- temp->next = NULL;
- temp->pre = NULL;
- return temp;
- }
- list* dob_second(list *l)
- {
- list *temp;
- temp = l->next;
- temp = new list;
- cout << "Введите данные для второго элемента в списке\n";
- cout << "\nВведите фамилию\n";
- cin >> temp->inf.surn;
- cout << "\nВведите имя\n";
- cin >> temp->inf.name;
- cout << "\nВведите отчество\n";
- cin >> temp->inf.ot;
- cout << "\nВведите день рождения\n";
- cin >> temp->inf.day;
- if (temp->inf.day > 31 || temp->inf.day < 1)
- {
- cout << "\nТакого числа не существует\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- cout << "\nВведите месяц рождения\n";
- cin >> temp->inf.month;
- if (temp->inf.month > 12 || temp->inf.day < 1)
- {
- cout << "Введено неверное число\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- if (temp->inf.month == 2 && temp->inf.day > 29)
- {
- cout << "\nВ феврале на может быть больше 29 дней\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- else
- {
- if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
- {
- cout << "\nТакой даты не сущетсвует\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- }
- cout << "\nВведите год рождения\n";
- cin >> temp->inf.year;
- if (temp->inf.year < 1950 || temp->inf.year>5000)
- {
- cout << "\nВведен неверный год\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- cout << "\nВведите пол\n";
- cout << "Подсказка:(w/m)\n";
- cin >> temp->inf.pol;
- if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
- {
- cout << "\nВы ввели не верный символ\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- cout << "\nВведите улицу\n";
- cin >> temp->inf.ad.street;
- cout << "\nВведите номер дома\n" << endl;
- cin >> temp->inf.ad.home;
- if (temp->inf.ad.home < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- cout << "\nВведите номер квартиры\n";
- cin >> temp->inf.ad.flate;
- if (temp->inf.ad.flate < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- delete temp;
- l->next = NULL;
- l->pre = NULL;
- return l;
- }
- temp->pre = l;
- temp->next = NULL;
- return temp;
- }
- list* add(list *r)
- {
- list *pr;
- pr = r;
- list *temp= new list;
- r->next = temp;
- cout << "Введите данные элемента в списке\n";
- cout << "\nВведите фамилию\n";
- cin >> temp->inf.surn;
- cout << "\nВведите имя\n";
- cin >> temp->inf.name;
- cout << "\nВведите отчество\n";
- cin >> temp->inf.ot;
- cout << "\nВведите день рождения\n";
- cin >> temp->inf.day;
- if (temp->inf.day > 31 || temp->inf.day < 1)
- {
- cout << "\nТакого числа не существует\n";
- system("pause");
- delete temp;
- return pr;
- }
- cout << "\nВведите месяц рождения\n";
- cin >> temp->inf.month;
- if (temp->inf.month > 12 || temp->inf.day < 1)
- {
- cout << "Введено неверное число\n";
- system("pause");
- delete temp;
- return pr;
- }
- if (temp->inf.month == 2 && temp->inf.day > 29)
- {
- cout << "\nВ феврале на может быть больше 29 дней\n";
- system("pause");
- delete temp;
- return pr;
- }
- else
- {
- if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
- {
- cout << "\nТакой даты не сущетсвует\n";
- system("pause");
- delete temp;
- return pr;
- }
- }
- cout << "\nВведите год рождения\n";
- cin >> temp->inf.year;
- if (temp->inf.year < 1950 || temp->inf.year>5000)
- {
- cout << "\nВведен неверный год\n";
- system("pause");
- delete temp;
- return pr;
- }
- cout << "\nВведите пол\n";
- cout << "Подсказка:(w/m)\n";
- cin >> temp->inf.pol;
- if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
- {
- cout << "\nВы ввели не верный символ\n";
- system("pause");
- delete temp;
- return pr;
- }
- cout << "\nВведите улицу\n";
- cin >> temp->inf.ad.street;
- cout << "\nВведите номер дома\n" << endl;
- cin >> temp->inf.ad.home;
- if (temp->inf.ad.home < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- delete temp;
- return pr;
- }
- cout << "\nВведите номер квартиры\n";
- cin >> temp->inf.ad.flate;
- if (temp->inf.ad.flate < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- delete temp;
- return pr;
- }
- temp->pre = r;
- temp->next = NULL;
- return temp;
- }
- void show(list *l, list *r)
- {
- char c1;
- list *temp;
- temp = l;
- if (l == NULL)
- {
- cout << "\nЭлементов нет\n";
- system("pause");
- return;
- }
- else {
- if (l == r)
- {
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- cout << "\n";
- return;
- }
- else
- {
- cout << "===================================================" << endl;
- cout << "Просмотр с первого" << endl;
- cout << "Просмотр с последнего " << endl;
- cout << "===================================================" << endl;
- cin >> c1;
- if (c1 == '1')
- {
- temp = l;
- cout << "\nОсуществляется просмотр сначала\n";
- for (; temp != r->next; temp = temp->next)
- {
- cout << "Фамилия " <<temp->inf.surn <<endl;
- cout << "Имя " << temp->inf.name <<endl;
- cout << "Отчество " << temp->inf.ot <<endl;
- cout << "День рождения " <<temp->inf.day <<endl;
- cout << "Месяц рождения " << temp->inf.month<<endl;
- cout << "Год рождения " << temp->inf.year<<endl;
- cout << "Пол " << temp->inf.pol<<endl;
- cout << "Улица " << temp->inf.ad.street<<endl;
- cout << "Дом "<< temp->inf.ad.home<<endl;
- cout << "Квартира " << temp->inf.ad.flate <<endl;
- cout << "\n";
- }
- }
- else
- {
- if (c1 == '2')
- {
- temp = r;
- cout << "\nОсуществляется просмотр с конца\n";
- for (; temp != NULL; temp = temp->pre)
- {
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- cout << "\n";
- }
- }
- }
- }
- }
- }
- list* del_first(list *l,list *r)
- {
- list *temp;
- if (l == NULL)
- {
- cout << "\nСписок пуст\n";
- system("pause");
- return NULL;
- }
- if (l->next == NULL)
- {
- delete l;
- l = NULL;
- cout << "\nЭлемент удален\n";
- system("pause");
- return NULL;
- }
- else
- {
- temp = l;
- l = temp->next;
- temp->next = NULL;
- delete temp;
- return l;
- }
- }
- list* del_last(list *r)
- {
- list* temp;
- temp = r;
- r = temp->pre;
- delete temp;
- r->next = NULL;
- return r;
- }
- void sohr(list *l,list *r)
- {
- }
- void search(list *l, list *r, int pois)
- {//от 49
- string str1;
- int ko;
- char ey;
- list *temp;
- temp = l;
- if (pois == 49 || pois == 50 || pois == 51)
- {
- if (pois == 49)
- {
- cout << "\nВведите фамилию\n";
- cin >> str1;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.surn == str1)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- system("pause");
- }
- if (pois == 50)
- {
- cout << "\nВведите имя\n";
- cin >> str1;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.name == str1)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- system("pause");
- }
- if (pois == 51)
- {
- cout << "\nВведите отчество\n";
- cin >> str1;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.ot == str1)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- system("pause");
- }
- }
- else
- {
- if (pois == 52 || pois == 53 || pois == 54 || pois == 55)
- {
- if (pois == 52)
- {
- cout << "\nВведите день рождения\n";
- cin >> ko;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.day == ko)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- system("pause");
- }
- if (pois == 53)
- {
- cout << "\nВведите месяц рождения\n";
- cin >> ko;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.month == ko)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- system("pause");
- }
- if (pois == 54)
- {
- cout << "\nВведите год рождения\n";
- cin >> ko;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.year == ko)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- system("pause");
- }
- if (pois == 55)
- {
- cout << "\nВведите пол\n";
- cin >> ey;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.pol == ey)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- system("pause");
- }
- }
- else
- {
- if (pois == 105)
- {
- cout << "Введите улицу\n";
- cin >> str1;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.ad.street == str1)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- }
- if (pois == 106)
- {
- cout << "Введите номер дома\n";
- cin >> ko;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.ad.home == ko)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- }
- if (pois == 107)
- {
- cout << "Введите номер квартиры\n";
- cin >> ko;
- for (; temp != NULL; temp = temp->next)
- {
- if (temp->inf.ad.flate == ko)
- {
- cout << "Найден клиент с такими данными" << endl;
- cout << "Информация\n\n";
- cout << "Фамилия " << temp->inf.surn << endl;
- cout << "Имя " << temp->inf.name << endl;
- cout << "Отчество " << temp->inf.ot << endl;
- cout << "День рождения " << temp->inf.day << endl;
- cout << "Месяц рождения " << temp->inf.month << endl;
- cout << "Год рождения " << temp->inf.year << endl;
- cout << "Пол " << temp->inf.pol << endl;
- cout << "Улица " << temp->inf.ad.street << endl;
- cout << "Дом " << temp->inf.ad.home << endl;
- cout << "Квартира " << temp->inf.ad.flate << endl;
- }
- }
- }
- }
- }
- }
- void tabl_show(list *l, list *r)
- {
- system("color 80");
- list* temp,*temp1,*temp2;
- string str4;
- cout <<setw(10)<< "Фамилия" << setw(10) << "Имя" << setw(18) << "Отчество" << setw(10) << "День" << setw(13) << "Месяц" << setw(10) << "Год" << setw(10) << "Пол" << setw(18) << "Улица" << setw(10) << "Дом" << setw(15) << "Квартира" <<setw(10)<< endl;
- cout << "_______________________________________________________________________________________________________________________________\n";
- for (temp = l; temp != NULL; temp = temp->next)
- {
- if (temp != l)
- {
- cout << "|----------+----------+------------------+----------+----------+----------+----------+------------------+----------+----------|\n";
- cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(18) << temp->inf.ot << "|" << setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
- }
- if(temp==l)
- cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(18)<< temp->inf.ot << "|"<< setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
- }
- cout << "-------------------------------------------------------------------------------------------------------------------------------\n";
- if (l != NULL)
- {
- cout << "\n\nСделать сортировку по фамилии?(Yes/No)\n";
- cin >> str4;
- if ("Yes" == str4 || "y" == str4 || "Y" == str4)
- {
- for (temp1 = l; temp1; temp1 = temp1->next)
- for (temp2 = temp1; temp2; temp2 = temp2->next)
- if (temp1->inf.surn > temp2->inf.surn)
- swap(temp1->inf, temp2->inf);
- system("cls");
- cout << setw(10) << "Фамилия" << setw(10) << "Имя" << setw(15) << "Отчество" << setw(10) << "День" << setw(13) << "Месяц" << setw(10) << "Год" << setw(10) << "Пол" << setw(18) << "Улица" << setw(10) << "Дом" << setw(15) << "Квартира" << setw(10) << endl;
- cout << "__________________________________________________________________________________________________________________________\n";
- for (temp = l; temp != NULL; temp = temp->next)
- {
- if (temp != l)
- {
- cout << "|----------+----------+---------------+----------+----------+----------+----------+---------------+----------+----------|\n";
- cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(15) << temp->inf.ot << "|" << setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
- }
- if (temp == l)
- cout << "|" << setw(10) << temp->inf.surn << "|" << setw(10) << temp->inf.name << "|" << setw(15) << temp->inf.ot << "|" << setw(10) << temp->inf.day << "|" << setw(10) << temp->inf.month << "|" << setw(10) << temp->inf.year << "|" << setw(10) << temp->inf.pol << "|" << setw(18) << temp->inf.ad.street << "|" << setw(10) << temp->inf.ad.home << "|" << setw(10) << temp->inf.ad.flate << "|" << endl;
- }
- cout << "-------------------------------------------------------------------------------------------------------------------------\n";
- }
- }
- system("pause");
- return;
- }
- void redak2(list *temp, list *zapas)
- {
- cout << "Введите новые данные\n";
- zapas->inf.surn = temp->inf.surn;
- zapas->inf.name = temp->inf.name;
- zapas->inf.ot = temp->inf.ot;
- zapas->inf.day = temp->inf.day;
- zapas->inf.month = temp->inf.month;
- zapas->inf.year = temp->inf.year;
- zapas->inf.pol = temp->inf.pol;
- zapas->inf.ad.street = temp->inf.ad.street;
- zapas->inf.ad.home = temp->inf.ad.home;
- zapas->inf.ad.flate = temp->inf.ad.flate;
- cout << "Введите фамилию\n";
- cin >> temp->inf.surn;
- cout << "Введите имя\n";
- cin >> temp->inf.name;
- cout << "Введите отчество\n";
- cin >> temp->inf.ot;
- cout << "Введите день рождения\n";
- cin >> temp->inf.day;
- if (temp->inf.day > 31 || temp->inf.day < 1)
- {
- cout << "\nТакого числа не существует\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "Введите месяц рождения\n";
- cin >> temp->inf.month;
- if (temp->inf.month > 12 || temp->inf.day < 1)
- {
- cout << "Введено неверное число\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- if (temp->inf.month == 2 && temp->inf.day > 29)
- {
- cout << "\nВ феврале на может быть больше 29 дней\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- else
- {
- if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
- {
- cout << "\nТакой даты не сущетсвует\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- }
- cout << "\nВведите год рождения\n";
- cin >> temp->inf.year;
- if (temp->inf.year < 1950 || temp->inf.year>5000)
- {
- cout << "\nВведен неверный год\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- if (temp->inf.month == 2 && temp->inf.year % 4 != 0 && temp->inf.day == 29)
- {
- cout << "Увы, это не високосный год\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "\nВведите пол\n";
- cout << "Подсказка:(w/m)\n";
- cin >> temp->inf.pol;
- if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
- {
- cout << "\nВы ввели не верный символ\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "\nВведите улицу\n";
- cin >> temp->inf.ad.street;
- cout << "\nВведите номер дома\n" << endl;
- cin >> temp->inf.ad.home;
- if (temp->inf.ad.home < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "\nВведите номер квартиры\n";
- cin >> temp->inf.ad.flate;
- if (temp->inf.ad.flate < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "Данные отредактированы\n";
- system("pause");
- }
- void redakt(list *l, list *r)
- {//по номеру элемента или по полю
- list *temp, *zapas;
- char q, q1;
- zapas = new list;
- int w, t;
- string str1;
- temp = l;
- if (l == NULL)
- {
- cout << "Список пуст\n";
- system("pause");
- return;
- }
- cout << "\nВыберите способ редктирования\n";
- cout << "1 Редактирование по номеру элемента\n";
- cout << "2 Редактирование по полю\n";
- cin >> q;
- if (q == '1')
- {
- w = 0;
- t = 0;
- cout << "Введите номер элемента\n";
- cin >> w;
- for (temp = l; temp != NULL; temp = temp->next)
- {
- t++;
- }
- if (w > t)
- {
- cout << "Введено большое число";
- system("pause");
- return;
- }
- t = 0;
- for (temp = l; temp != NULL; temp = temp->next)
- {
- t++;
- if (t == w)
- {
- zapas->inf.surn = temp->inf.surn;
- zapas->inf.name = temp->inf.name;
- zapas->inf.ot = temp->inf.ot;
- zapas->inf.day = temp->inf.day;
- zapas->inf.month = temp->inf.month;
- zapas->inf.year = temp->inf.year;
- zapas->inf.pol = temp->inf.pol;
- zapas->inf.ad.street = temp->inf.ad.street;
- zapas->inf.ad.home = temp->inf.ad.home;
- zapas->inf.ad.flate = temp->inf.ad.flate;
- cout << "Введите данные о пользователе\n ";
- cout << "Введите фамилию\n";
- cin >> temp->inf.surn;
- cout << "Введите имя\n";
- cin >> temp->inf.name;
- cout << "Введите отчество\n";
- cin >> temp->inf.ot;
- cout << "Введите день рождения\n";
- cin >> temp->inf.day;
- if (temp->inf.day > 31 || temp->inf.day < 1)
- {
- cout << "\nТакого числа не существует\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "Введите месяц рождения\n";
- cin >> temp->inf.month;
- if (temp->inf.month > 12 || temp->inf.day < 1)
- {
- cout << "Введено неверное число\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- if (temp->inf.month == 2 && temp->inf.day > 29)
- {
- cout << "\nВ феврале на может быть больше 29 дней\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- else
- {
- if ((temp->inf.month == 4 || temp->inf.month == 6 || temp->inf.month == 9 || temp->inf.month == 11) && temp->inf.day == 31)
- {
- cout << "\nТакой даты не сущетсвует\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- }
- cout << "\nВведите год рождения\n";
- cin >> temp->inf.year;
- if (temp->inf.year < 1950 || temp->inf.year>5000)
- {
- cout << "\nВведен неверный год\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- if (temp->inf.month == 2 && temp->inf.year % 4 != 0 && temp->inf.day == 29)
- {
- cout << "Увы, это не високосный год\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "\nВведите пол\n";
- cout << "Подсказка:(w/m)\n";
- cin >> temp->inf.pol;
- if (temp->inf.pol != 'w' && temp->inf.pol != 'm')
- {
- cout << "\nВы ввели не верный символ\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "\nВведите улицу\n";
- cin >> temp->inf.ad.street;
- cout << "\nВведите номер дома\n" << endl;
- cin >> temp->inf.ad.home;
- if (temp->inf.ad.home < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "\nВведите номер квартиры\n";
- cin >> temp->inf.ad.flate;
- if (temp->inf.ad.flate < 1)
- {
- cout << "\nВы ввели не верное число\n";
- system("pause");
- temp->inf.surn = zapas->inf.surn;
- temp->inf.name = zapas->inf.name;
- temp->inf.ot = zapas->inf.ot;
- temp->inf.day = zapas->inf.day;
- temp->inf.month = zapas->inf.month;
- temp->inf.year = zapas->inf.year;
- temp->inf.pol = zapas->inf.pol;
- temp->inf.ad.street = zapas->inf.ad.street;
- temp->inf.ad.home = zapas->inf.ad.home;
- temp->inf.ad.flate = zapas->inf.ad.flate;
- return;
- }
- cout << "Данные отредактированы\n";
- system("pause");
- }
- }
- }
- if (q == '2')
- {
- cout << "\nВведите номер поля, по которому надо сделать редактирование\n";
- cout << "1.Фамилия " << endl;
- cout << "2.Имя " << endl;
- cout << "3.Отчество " << endl;
- cout << "4.День рождения " << endl;
- cout << "5.Месяц рождения " << endl;
- cout << "6.Год рождения " << endl;
- cout << "7.Пол " << endl;
- cout << "8.Адрес " << endl;
- cin >> q1;
- if (q1 != '8')
- {
- if (q1 == '1')
- {
- cout << "\nВведите фамилию,которую надо заменить\n";
- cin >> str1;
- for (temp = l; temp != NULL; temp = temp->next)
- {
- if (str1 == temp->inf.surn)
- {
- cout << "\nНайден пользователь с данной фамилией\n";
- redak2(temp,zapas);
- }
- }
- }
- if (q1 == '2')
- {
- cout << "\nВведите имя,которое надо заменить\n";
- cin >> str1;
- for (temp = l; temp != NULL; temp = temp->next)
- {
- if (str1 == temp->inf.name)
- {
- cout << "\nНайден пользователь с данным именем\n";
- redak2(temp, zapas);
- }
- }
- }
- if (q1 == '3')
- {
- cout << "\nВведите отчество,которое надо заменить\n";
- cin >> str1;
- for (temp = l; temp != NULL; temp = temp->next)
- {
- if (str1 == temp->inf.ot)
- {
- cout << "\nНайден пользователь с данным отчеством\n";
- redak2(temp, zapas);
- }
- }
- }
- }
- }
- else
- {
- cout << "\nВведен неверный символ\n";
- system("pause");
- return;
- }
- }
- /*
- void myfunc(list *l,list *r)
- {
- int k,i,n,j;
- list *temp, *l2,*r2;
- string *mas,*a;
- int *imas;
- string str,str1;
- if (l == NULL)
- {
- cout << "\nСписок пуст\n";
- }
- for
- }*/
- /* int k,i,n,j;
- int imas;*/
- /* while (1)
- {
- while (str == a[i] && i < k + 1)
- {
- i++; k++;
- }
- if (i - 1 < k)
- {
- str =a[i]
- }
- }*/
- void saveinfiletxt(list *temp)
- {
- list *t;
- t = temp;
- ofstream f("1.txt",ios::out);
- if (!f)
- {
- cout << "\nНевозможно открыть файл\n";
- system("pause");
- return;
- }
- while (t != NULL)
- {
- f << t->inf.surn<<"\n";
- f << t->inf.name<< "\n";
- f << t->inf.ot << "\n";
- f << t->inf.day << "\n";
- f << t->inf.month << "\n";
- f << t->inf.year << "\n";
- f << t->inf.pol << "\n";
- f << t->inf.ad.street << "\n";
- f << t->inf.ad.home << "\n";
- f << t->inf.ad.flate << "\n";
- t = t->next;
- }
- cout << "Сохранение в текстовый файл выполнено\n";
- system("pause");
- f.close();
- }
- void readoutfiletxt(list *l)
- {
- ifstream fin("1.txt",ios::in);
- list *temp;
- string str;
- int d;
- d = 0;
- if(!fin)
- {
- cout << "\nФайл нельзя открыть\n";
- system("pause");
- return;
- }
- l = new list;
- temp = l;
- fin.seekg(0, ios::beg);
- while (!EOF)
- {
- getline(fin, temp->inf.surn);
- getline(fin, temp->inf.name);
- getline(fin, temp->inf.ot);
- /* getline(fin, temp->inf.day);
- getline(fin, temp->inf.month);
- getline(fin, temp->inf.year);
- getline(fin, temp->inf.pol);
- getline(fin, temp->inf.ad.street);
- getline(fin, temp->inf.ad.home);
- getline(fin, temp->inf.ad.flate);
- d++;
- */
- // temp->
- }
- cout << temp->inf.surn<<" fam"<<endl;
- cout << temp->inf.name <<" nam"<< endl;
- cout << temp->inf.ot << "double nam"<<endl;
- cout << temp->inf.day << " lf"<<endl;
- cout << temp->inf.month << endl;
- /* cout << temp->inf.year << endl;
- cout << temp->inf.pol << endl;
- cout << temp->inf.ad.street << endl;
- cout << temp->inf.ad.home << endl;
- cout << temp->inf.ad.flate << endl;*/
- system("pause");
- }
- void saveinbinarfile(list *tem)
- {
- ofstream out("2.txt", ios::out, ios::binary);
- if (!out)
- {
- cout << "Файл не удалось открыть";
- system("pause");
- return;
- }
- list *t;
- t = tem;
- while (t != NULL)
- {
- out.write((char*)&t->inf, sizeof(t->inf));
- t = t->next;
- }
- out.close();
- return;
- }/*
- list* readoutbinarfile(list* l,list* r)
- {
- int d;
- d = 0;
- list* t,*t1;
- if (l == NULL)
- {
- t = l;
- }
- ifstream in("2.txt",ios::in ,ios::binary);
- while (in)
- {
- d++;
- t = new list;
- in.read((char*)&t->inf, sizeof(t->inf));
- cout << "ttt" << endl;
- if (d == 1)
- {
- l = t;
- t1 = l;
- r = t;
- }
- else
- {
- t->pre = r;
- r->next = t;
- r = t;
- }
- };
- in.close();
- return l;
- }
- */
- void sort(list* l, list* r)
- {
- list* temp1, *temp2;
- for (temp1 = l; temp1; temp1 = temp1->next)
- for (temp2 = temp1; temp2; temp2 = temp2->next)
- if (temp1->inf.ad.street > temp2->inf.ad.street)
- swap(temp1->inf, temp2->inf);
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- list *l, *r,*t,*td;
- string namefile;
- int pois,value;
- wint_t c;
- char c2, c21,c3,c0;
- int k;
- SendMessage(GetConsoleWindow(), WM_SYSKEYDOWN, VK_RETURN, 0x20000000);
- l = NULL;
- r = NULL;
- // system("cls");
- while(1)
- {
- system("color 80");
- SetColor(15, 8);
- cout << "========================================================================================================================================================================" << endl;
- cout << setw(2950) << "1 Добавить элемент ";
- SetColor(8, 8);
- cout<< setw(74) << "|" << endl;
- SetColor(15, 8);
- cout << setw(86) << "2 Просмотр ";
- SetColor(8, 8);
- cout<<setw(82)<<"|"<< endl;
- SetColor(15, 8);
- cout << setw(94) << "3 Популярные улицы ";
- SetColor(8, 8);
- cout << setw(74) << "|" << endl;
- SetColor(15, 8);
- cout << setw(79) << "4 ";
- SetColor(8, 8);
- cout << setw(89) << "|" << endl;
- SetColor(15, 8);
- cout << setw(83) << "5 Поиск ";
- SetColor(8, 8);
- cout<<setw(85)<<"|"<< endl;
- SetColor(15, 8);
- cout << setw(92) << "6 Редактирование ";
- SetColor(8, 8);
- cout<< setw(76)<<"|"<< endl;
- SetColor(15, 8);
- cout << setw(82) << "7 Файл ";
- SetColor(8, 8);
- cout<< setw(86)<<"|"<< endl;
- SetColor(15, 8);
- cout << setw(86) << "8 Удаление ";
- SetColor(8, 8);
- cout << setw(82) << "|" << endl;
- SetColor(15, 8);
- cout << setw(83) << "9 Выход ";
- SetColor(8, 8);
- cout << setw(85) << "|" << endl;
- SetColor(15, 8);
- cout << setw(3360)<<"========================================================================================================================================================================" << endl;
- // c = cin.get();
- // cin >> c;
- c = _getwch();
- switch (c)
- {
- case '1':
- if (l == NULL)
- {
- system("cls");
- l = create();
- r = l;
- }
- else
- {
- if (l->next == NULL)
- {
- system("cls");
- r = dob_second(l);
- if (l != r)
- {
- l->next = r;
- r->pre = l;
- r->next = NULL;
- }
- }
- else
- {
- system("cls");
- r = add(r);
- }
- }
- break;
- case '2':
- system("CLS");
- cout << "Выберите номер желаемого просмотра\n";
- cout << "1 Просмотр таблицей\n";
- cout << "2 Обычный просмотр\n";
- cin >> c0;
- if (c0 == '1')
- {
- system("CLS");
- // SetColor(0, 15);
- tabl_show(l, r);
- }
- if (c0 == '2')
- {
- system("CLS");
- show(l, r);
- system("pause");
- }
- break;
- case '3':
- sort(l,r);
- myfunc(l, r);
- break;
- case '4':
- // myfunc(l,r);
- break;
- case '5':
- cout << "\nВведите номер поля, по которому будет происходить поиск\n";
- cout << "1.Фамилия " << endl;
- cout << "2.Имя " << endl;
- cout << "3.Отчество " << endl;
- cout << "4.День рождения " << endl;
- cout << "5.Месяц рождения " << endl;
- cout << "6.Год рождения " << endl;
- cout << "7.Пол " << endl;
- cout << "8.Адрес " << endl;
- cin >> c2;
- if (c2 != '8')
- {
- search(l, r, c2);
- }
- else
- {
- cout << "Выберите номер поля адреса\n";
- cout << " 1.Улица" << endl;
- cout << " 2.Дом" << endl;
- cout << " 3.Квартира" << endl;
- cin >> c21;
- int y = c21+c2;
- search(l, r, y);
- system("pause");
- }
- break;
- case '6':
- redakt(l,r);
- break;
- case '7':
- system("CLS");
- cout << "1 Чтение с тесктового файла\n";
- cout << "2 Сохранение в текстовый файл\n";
- cout << "3 Чтение с типизированного файла\n";
- cout << "4 Сохраниние в типизированный файл\n";
- cin >> c3;
- if (c3 == '1')
- {
- cout << "1\n";
- readoutfiletxt(l);
- }
- if (c3 == '2')
- {
- cout << "2\n";
- saveinfiletxt(l);
- }
- if (c3 == '3')
- {
- l=readoutbinarfile(l,r);
- }
- if (c3 == '4')
- {
- saveinbinarfile(l);
- }
- break;
- case '8':
- cout << "\nВведите номер элемента для удаления\n";
- cin >> value;
- if (value == 1)
- {
- l=del_first(l, r);
- }
- else
- {
- k = 0;
- for (t = l; t != NULL; t = t->next)
- {
- k++;
- }
- if (value <= k)
- {
- if (value < k)
- {
- k = 0;
- td = l;
- for (t = l; t != NULL; t = t->next)
- {
- k++;
- if (k == value)
- {
- t->pre->next = t->next;
- t->next->pre = t->pre;
- }
- }
- delete t;
- }
- if (value == k)
- {
- r = del_last(r);
- }
- }
- else
- {
- cout << "\nБыло введено большое число\n";
- system("pause");
- }
- }
- break;
- case 27:
- if(IDOK== MessageBox(NULL, L"Вы действительно хотите выйти?", L"Account Details", MB_OKCANCEL | MB_ICONQUESTION | MB_SETFOREGROUND))
- return 0;
- }
- };
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement