Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <stdlib.h>
- #include <locale.h>
- typedef struct Flat
- {
- int floor, countRoom, Square;
- struct {
- char district[20];
- char street[20];
- }Adress;
- struct Flat* next;
- } Flat;
- Flat *First, *Last, *el;
- void push(int inf, int max)
- {
- int tmp;
- while(1)
- {
- struct Flat* el;
- el = (struct Flat*)malloc(sizeof(struct Flat));
- if (el == NULL)
- {
- printf("Не удалось выделить память под элемент списка.\n");
- return;
- }
- el->next = NULL;
- if (First == NULL)
- First = Last = el;
- else
- {
- Last->next = el;
- Last = Last->next;
- }
- printf("Введите данные квартиры: \n");
- printf("Введите количество комнат: ");
- scanf("%d", &el->countRoom);
- printf("\nВведите площадь комнаты: ");
- scanf("%d", &el->Square);
- printf("\nВведите этаж: ");
- scanf("%d", &el->floor);
- printf("\nВведите район: ");
- scanf("%s", &(el->Adress.district));
- printf("\nВведите район: ");
- scanf("%s", &(el->Adress.street));
- }
- int main(void)
- {
- setlocale(LC_ALL, "Russian");
- First = Last = NULL;
- printf("Введите элементы списка (окончание ввода -- любой символ, кроме цифры):\n");
- while (scanf("%d", &inf) != 0)
- {
- push(inf,max);
- k++;
- }
- for (el = First; el != Last; el = el->next)
- if (el->info > max)
- max= el->info;
- el = First;
- while (el != NULL)
- {
- tmp = First;
- if (el->info == max)
- {
- if (el == First)
- {
- First = el->next;
- el = el->next;
- }
- else
- {
- while (tmp->next != el)
- tmp = tmp->next;
- tmp->next = el->next;
- el=el->next;
- }
- }
- else
- el = el->next;
- }
- printf("\n");
- for (el = First; el != NULL; el = el->next)
- {
- printf("%d ", el->info);
- }
- for (el = First; el != NULL;)
- {
- tmp = el;
- el = el->next;
- free(tmp);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement