Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- struct listFirstFile{
- int lectureHall;
- int PCSerial;
- string pulpit;
- string surname;
- string name;
- string patronymic;
- listFirstFile *prev, *next;
- };
- int main() {
- setlocale(LC_ALL, "Russian");
- int sizeOf_FirstFile = 0;
- int c, position;
- bool isDone = false;
- listFirstFile* FirstFile = new listFirstFile;
- listFirstFile* headFirstFile = NULL;
- listFirstFile* tailFirstFile = NULL;
- while (!isDone){
- listFirstFile *temp = new listFirstFile;
- listFirstFile *tempHead = headFirstFile;
- cout << "\t\tВведите номер аудитории: " << endl;
- cin >> (temp->lectureHall);
- cout << "\t\tВведите номер компьютера: " << endl;
- cin >> temp->PCSerial;
- cout << "\t\tВведите кафедру: \n>";
- cin >> temp->pulpit;
- cout << "\t\tВведите фамилию отвественного: \n>";
- cin >> temp->surname;
- cout << "\t\tВведите имя отвественного: \n>";
- cin >> temp->name;
- cout << "\t\tВведите отчество отвественного: \n>";
- cin >> temp->patronymic;
- system("cls");
- cout << "\n\tВы ввели: " << endl;
- cout << "|" << temp->lectureHall << "|" << temp->PCSerial << "|" << temp->pulpit << "|" << temp->surname << "|" << temp->name << "|" << temp->patronymic << endl;
- cout << "\n\tВыберите действие:\n\t\t1. Быстрое добавление\n\t\t2. Точечное добавление" << endl;
- cin >> c;
- system("cls");
- switch (c) {
- case 1: {
- if (headFirstFile == NULL) {
- temp->prev = NULL;
- temp->next = NULL;
- tailFirstFile = temp;
- headFirstFile = temp;
- sizeOf_FirstFile++;
- }
- else {
- tailFirstFile->next = temp;
- temp->next = NULL;
- temp->prev = tailFirstFile;
- tailFirstFile = temp;
- sizeOf_FirstFile++;
- }
- break;
- }
- case 2: {
- cin >> position;
- if (position == 1) {
- temp->prev = NULL;
- temp->next = headFirstFile;
- headFirstFile = temp;
- sizeOf_FirstFile++;
- }
- else if (position <= sizeOf_FirstFile) {
- for (int i = 1; i <= sizeOf_FirstFile; i++)
- {
- if (position == i)
- {
- temp->prev = tempHead->prev;
- (tempHead->prev)->next = temp;
- temp->next = tempHead;
- }
- tempHead = tempHead->next;
- }
- sizeOf_FirstFile++;
- }
- else {
- tailFirstFile->next = temp;
- temp->next = NULL;
- temp->prev = tailFirstFile;
- tailFirstFile = temp;
- sizeOf_FirstFile++;
- }
- }
- }
- cout << "\tПолный список записей из Файла 1:" << endl;
- cout << "|" << "Аудитория" << "|" << "Номер ЭВМ " << "|" << "Кафедра" << "|" << "Фамилия отвественного " << "|" << "Имя отвественного" << "|" << "Отчество отвественного " << endl;
- while (headFirstFile != NULL) {
- cout << "|" << headFirstFile->lectureHall << "|" << headFirstFile->PCSerial <<"|" << headFirstFile->pulpit << "|" << headFirstFile->surname << "|" << headFirstFile->name << "|" << headFirstFile->patronymic << "\n";
- headFirstFile = headFirstFile->next;
- }
- cout << "Добавить еще?\n 1. Да\n 2. Нет" <<endl;
- cin >> c;
- switch (c){
- case 1:{
- break;
- }
- case 2:{
- isDone = true;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement