Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.78 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <locale.h>
  5.  
  6.  
  7.  typedef struct Flat
  8.  {
  9.      int floor, countRoom, Square;
  10.      struct {
  11.          char district[20];
  12.          char street[20];
  13.      }Adress;
  14.      struct Flat* next;
  15.  } Flat;
  16.  
  17.  
  18. Flat *First, *Last, *el;
  19.  
  20. void push()
  21. {
  22.     int tmp = 0;
  23.     while(1)
  24. {
  25.         struct Flat* el;
  26.         el = (struct Flat*)malloc(sizeof(struct Flat));
  27.         if (el == NULL)
  28.         {
  29.             printf("Не удалось выделить память под элемент списка.\n");
  30.             return;
  31.         }
  32.         el->next = NULL;
  33.  
  34.         if (First == NULL)
  35.             First = Last = el;
  36.         else
  37.         {
  38.             Last->next = el;
  39.             Last = Last->next;
  40.         }
  41.     printf("Введите данные квартиры. \n");
  42.     printf("Введите количество комнат: ");
  43.     scanf("%d", &el->countRoom);
  44.     printf("Введите площадь комнаты: ");
  45.     scanf("%d", &el->Square);
  46.     printf("Введите этаж: ");
  47.     scanf("%d", &el->floor);
  48.     printf("Введите район: ");
  49.     scanf("%c", &(el->Adress.district));
  50.     printf("Введите улицу: ");
  51.     scanf("%c", &(el->Adress.street));
  52.     printf("Хотите ввести еще квартиру? (1 - да, 0 - нет): ");
  53.     scanf("%d",&tmp);
  54.     if(tmp == 0)
  55.     {
  56.         printf("Ну как хотите. Досвидания.");
  57.         break;
  58.     }
  59. }
  60.    
  61. }
  62.  
  63.  
  64. int main(void)
  65. {
  66.     push();
  67. //    setlocale(LC_ALL, "Russian");
  68. //    First = Last = NULL;
  69. //
  70. //    printf("Введите элементы списка (окончание ввода -- любой символ, кроме цифры):\n");
  71. //    while (scanf("%d", &inf) != 0)
  72. //    {
  73. //        push(inf,max);
  74. //        k++;
  75. //    }
  76. //    for (el = First; el != Last; el = el->next)
  77. //        if (el->info > max)
  78. //            max= el->info;
  79. //
  80. //    el = First;
  81. //    while (el != NULL)
  82. //    {
  83. //        tmp = First;
  84. //        if (el->info == max)
  85. //        {
  86. //            if (el == First)
  87. //            {
  88. //                First = el->next;
  89. //                el = el->next;
  90. //            }
  91. //            else
  92. //            {
  93. //                while (tmp->next != el)
  94. //                    tmp = tmp->next;
  95. //                tmp->next = el->next;
  96. //                el=el->next;
  97. //            }
  98. //        }
  99. //        else
  100. //            el = el->next;
  101. //        }
  102. //
  103. //    printf("\n");
  104. //
  105. //    for (el = First; el != NULL; el = el->next)
  106. //    {
  107. //        printf("%d ", el->info);
  108. //    }
  109. //
  110. //    for (el = First; el != NULL;)
  111. //    {
  112. //        tmp = el;
  113. //        el = el->next;
  114. //        free(tmp);
  115. //    }
  116.     return 0;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement