Advertisement
s3nnou

Untitled

May 12th, 2019
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct listFirstFile{
  6. int lectureHall;
  7. int PCSerial;
  8. string pulpit;
  9. string surname;
  10. string name;
  11. string patronymic;
  12. listFirstFile *prev, *next;
  13. };
  14.  
  15. int main() {
  16. setlocale(LC_ALL, "Russian");
  17.  
  18. int sizeOf_FirstFile = 0;
  19. int c, position;
  20. bool isDone = false;
  21.  
  22. listFirstFile* FirstFile = new listFirstFile;
  23. listFirstFile* headFirstFile = NULL;
  24. listFirstFile* tailFirstFile = NULL;
  25.  
  26. while (!isDone){
  27.  
  28. listFirstFile *temp = new listFirstFile;
  29. listFirstFile *tempHead = headFirstFile;
  30.  
  31. cout << "\t\tВведите номер аудитории: " << endl;
  32. cin >> (temp->lectureHall);
  33. cout << "\t\tВведите номер компьютера: " << endl;
  34. cin >> temp->PCSerial;
  35. cout << "\t\tВведите кафедру: \n>";
  36. cin >> temp->pulpit;
  37. cout << "\t\tВведите фамилию отвественного: \n>";
  38. cin >> temp->surname;
  39. cout << "\t\tВведите имя отвественного: \n>";
  40. cin >> temp->name;
  41. cout << "\t\tВведите отчество отвественного: \n>";
  42. cin >> temp->patronymic;
  43.  
  44. system("cls");
  45. cout << "\n\tВы ввели: " << endl;
  46. cout << "|" << temp->lectureHall << "|" << temp->PCSerial << "|" << temp->pulpit << "|" << temp->surname << "|" << temp->name << "|" << temp->patronymic << endl;
  47.  
  48. cout << "\n\tВыберите действие:\n\t\t1. Быстрое добавление\n\t\t2. Точечное добавление" << endl;
  49. cin >> c;
  50. system("cls");
  51.  
  52. switch (c) {
  53. case 1: {
  54. if (headFirstFile == NULL) {
  55. temp->prev = NULL;
  56. temp->next = NULL;
  57. tailFirstFile = temp;
  58. headFirstFile = temp;
  59. sizeOf_FirstFile++;
  60. }
  61. else {
  62. tailFirstFile->next = temp;
  63. temp->next = NULL;
  64. temp->prev = tailFirstFile;
  65. tailFirstFile = temp;
  66. sizeOf_FirstFile++;
  67. }
  68.  
  69. break;
  70. }
  71. case 2: {
  72. cin >> position;
  73. if (position == 1) {
  74. temp->prev = NULL;
  75. temp->next = headFirstFile;
  76. headFirstFile = temp;
  77. sizeOf_FirstFile++;
  78. }
  79. else if (position <= sizeOf_FirstFile) {
  80. for (int i = 1; i <= sizeOf_FirstFile; i++)
  81. {
  82. if (position == i)
  83. {
  84. temp->prev = tempHead->prev;
  85. (tempHead->prev)->next = temp;
  86. temp->next = tempHead;
  87. }
  88. tempHead = tempHead->next;
  89. }
  90. sizeOf_FirstFile++;
  91. }
  92. else {
  93. tailFirstFile->next = temp;
  94. temp->next = NULL;
  95. temp->prev = tailFirstFile;
  96. tailFirstFile = temp;
  97. sizeOf_FirstFile++;
  98. }
  99. }
  100. }
  101. cout << "\tПолный список записей из Файла 1:" << endl;
  102. cout << "|" << "Аудитория" << "|" << "Номер ЭВМ " << "|" << "Кафедра" << "|" << "Фамилия отвественного " << "|" << "Имя отвественного" << "|" << "Отчество отвественного " << endl;
  103.  
  104. while (headFirstFile != NULL) {
  105. cout << "|" << headFirstFile->lectureHall << "|" << headFirstFile->PCSerial <<"|" << headFirstFile->pulpit << "|" << headFirstFile->surname << "|" << headFirstFile->name << "|" << headFirstFile->patronymic << "\n";
  106. headFirstFile = headFirstFile->next;
  107. }
  108.  
  109.  
  110. cout << "Добавить еще?\n 1. Да\n 2. Нет" <<endl;
  111. cin >> c;
  112. switch (c){
  113. case 1:{
  114. break;
  115. }
  116. case 2:{
  117. isDone = true;
  118. break;
  119. }
  120. }
  121.  
  122. }
  123.  
  124.  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement