Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- struct base
- {
- char znak;
- struct base *next;
- };
- struct base *add_stack(struct base *stos, char znak)
- {
- struct base *nowy = (struct base*)
- malloc(sizeof(struct base));
- if(nowy!=NULL)
- {
- nowy->znak = znak;
- nowy->next = stos;
- stos = nowy;
- }
- return stos;
- }
- void delete_stack(struct base **stos)
- {
- struct base *tmp;
- while(*stos)
- {
- tmp = (*stos)->next;
- printf("%c\t", (*stos)->znak);
- free(*stos);
- (*stos) = tmp;
- }
- }
- int main()
- {
- char znak;
- struct base *stos = NULL;
- int i = 0;
- for(i; i < 5; i++)
- {
- printf("Podaj znak: ");
- scanf("%c", &znak);
- while(getchar()!='\n');
- stos = add_stack(stos, znak);
- }
- delete_stack(&stos);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement