Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as C++ by hedgehoge ( 13 years ago )
// PT_domace_1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>


struct zaznam{
 int cislo;
 struct zaznam* next;
};

void tlac(struct zaznam* aktualny)
{
 while(aktualny!=NULL)
 {
  printf("%d\n",aktualny->cislo);
  aktualny=aktualny->next; 
 
 }
}

void dopln_na_koniec(struct zaznam* prvy,int nove_cislo)
{
 while(prvy->next!=NULL)
 {
  prvy=prvy->next;
  
 }
 prvy=(struct zaznam*)malloc(sizeof(zaznam));
 prvy->cislo=nove_cislo;
 prvy->next=NULL;
 printf("pridane cisla na koniec zoznamu %d\n",prvy->cislo);
}

int main()
{
  struct zaznam *zaciatok;
 
  
  zaciatok=(struct zaznam*)malloc(sizeof(struct zaznam));
  zaciatok->cislo=1;
  zaciatok->next=(struct zaznam*)malloc(sizeof(struct zaznam));
  zaciatok->next->cislo=2;
  zaciatok->next->next=(struct zaznam*)malloc(sizeof(struct zaznam));
  zaciatok->next->next->cislo=3;
  zaciatok->next->next->next=(struct zaznam*)malloc(sizeof(struct zaznam));
  zaciatok->next->next->next->cislo=4;
  zaciatok->next->next->next->next=NULL;

 tlac(zaciatok);

 dopln_na_koniec(zaciatok,5);

 
 return 0;
}

 

Revise this Paste

Your Name: Code Language: