Код: Выделить всё
#include <stdlib.h>
#include <stdio.h>
typedef struct LIST{
int val;
struct LIST *ptr;
};
LIST *head = NULL;
LIST *tail = NULL;
LIST *tek_ptr;
//добавление
void push(int n){
tek_ptr = (LIST*)malloc(sizeof(LIST));
tek_ptr->val = n;
if(head == NULL && tail == NULL)
head = tek_ptr;
else
tail->ptr = tek_ptr;
tail = tek_ptr;
tail->ptr = NULL;
}
//извлечение и вывод
void pop(){
tek_ptr = head;
while(tek_ptr!= NULL){
printf("%d", tek_ptr->val);
tek_ptr = tek_ptr->ptr;
}
}
int main(){
int n;
scanf("%d", &n);
push(n);
scanf("%d", &n);
push(n);
scanf("%d", &n);
push(n);
pop();
return 0;
}