Advertisement
Guest User

spisok

a guest
Apr 22nd, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <iostream>
  3. #include <string>
  4. #include <Windows.h>
  5. #include <fstream>
  6. #include <cstdio>
  7. using namespace std;
  8. struct List {
  9. string name;
  10. char rayon1[20];
  11. char rayon2[20];
  12. char rayon3[20];
  13. List *nxt;
  14. };
  15. void vvod(List* head, int n, int size) {
  16. List* tmp = head;
  17. ifstream fin("ss.txt");
  18. for (int i = 0; i < n; ++i) {
  19. if (i) {
  20. tmp->nxt = new List;
  21. tmp = tmp->nxt;
  22. size++;
  23. }
  24. fin >> tmp->name;
  25. fin >> tmp->rayon1;
  26. fin >> tmp->rayon2;
  27. fin >> tmp->rayon3;
  28. tmp->nxt = NULL;
  29. }
  30. fin.close();
  31. }/*
  32. void remove_element(List *head, int n, int size)
  33. {
  34.  
  35. List* tmp = head;
  36. int i = 0;
  37. List* prev = NULL;
  38. if (head!=NULL && n < size)
  39. {
  40. while(tmp && i < n-1) {
  41. ++i;
  42. prev = tmp;
  43. tmp = tmp->nxt;
  44. }
  45. if (!tmp) {
  46. return;
  47. }
  48. if (head == tmp)
  49. {
  50. head = tmp->nxt;
  51. }
  52. else
  53. {
  54. if (prev) {
  55. prev->nxt = tmp->nxt;
  56. }
  57. }
  58. size--;
  59. delete(tmp);
  60. }
  61. }*/
  62. void vivod(List *head, int n) {
  63. List* tmp = head;
  64. for (int i = 0; i < n; ++i) {
  65. cout << " NOMER " << i + 1 << endl;
  66. cout << tmp->name;
  67. cout << endl;
  68. cout << tmp->rayon1 << " " << tmp->rayon2 << " " << tmp->rayon3 << endl;
  69. tmp = tmp->nxt;
  70. }
  71. }
  72. void redaktirovat(int zbPos, List *head, string name, char rayon1[20], char rayon2[20], char rayon3[20], char s[20], char s1[20], char s2[20], string gorod)
  73. {
  74. for (int i = 0; i < zbPos; ++i)
  75. head = head->nxt;
  76.  
  77. head->name = gorod;
  78. strcpy(head->rayon1, s);
  79. strcpy(head->rayon2, s1);
  80. strcpy(head->rayon3, s2);
  81. }
  82. int main()
  83. {
  84. List *head = new List;
  85. int n=0;
  86. int zbPos;
  87. string gorod;
  88. char stroka[20];
  89. char stroka1[20];
  90. char stroka2[20];
  91. int z = 0;
  92. cout << " Vvedite kolichestvo gorodov " << endl;
  93. cin >> n;
  94. int size = n;
  95. vvod(head, n, size);
  96. //cout << "size:" << size << endl;
  97. vivod(head, n);
  98. cout << " Cho pomenyat? " << endl;
  99. cin >> zbPos;
  100. cin.ignore();
  101. cout << " Gorod -> " << endl;
  102. cin >> gorod;
  103. cin.ignore();
  104. cout << " Rayon1-> " << endl;
  105. cin.getline(stroka, 20, '\n');
  106. cin.ignore();
  107. cout << " Rayon2-> " << endl;
  108. cin.getline(stroka1, 20, '\n');
  109. cin.ignore();
  110. cout << " Rayon3-> " << endl;
  111. cin.getline(stroka2, 20, '\n');
  112. redaktirovat(zbPos, head, head->name, head->rayon1, head->rayon2, head->rayon3, stroka, stroka1, stroka2, gorod);
  113. //cout << "Cho udalit? " << endl;
  114. //cin >> z;
  115. //remove_element(head, z, size);
  116. vivod(head, n);
  117. system("pause");
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement