Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- /*
- * File: main.c
- * Author: Powerpes
- *
- * Created on 14. září 2016, 16:26
- */
- #include <stdio.h>
- #include <stdlib.h>
- typedef struct prv{
- int hodnota;
- struct prv* predchozi;
- }prvek;
- prvek* pridej(prvek *zasobnik, int data){
- prvek* pridany = malloc(sizeof(prvek));
- pridany->hodnota = data;
- pridany->predchozi = zasobnik;
- return pridany;
- }
- int vrchol(prvek* zasobnik){
- if (zasobnik == NULL)
- return 0;
- return zasobnik->hodnota;
- }
- prvek* odeber(prvek* zasobnik){
- if (zasobnik == NULL)
- return 0;
- prvek* stary = zasobnik-> predchozi;
- free(zasobnik);
- return stary;
- }
- int main(int argc, char** argv) {
- prvek* z=NULL;
- z = pridej(z, 201010);
- z = pridej(z, 225);
- z = pridej(z, 2222);
- z = pridej(z, 2350);
- while (z!=NULL){
- z=odeber(z);
- z=odeber(z);
- z=odeber(z);
- printf("%i\n", vrchol(z));
- }
- return (EXIT_SUCCESS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement