Pregled posta

Adresa bloga: https://blog.dnevnik.hr/prirodaa

Marketing

jednostruka lista,dok ne unese 0,0na kraju

#include
using namespace std;
struct node{
int data;
node *link;
};
void ispis(node *head);
void unos(node *&head);

int main()
{
node *head=0;
unos(head);
ispis(head);
node *temp;
while(head)
{
temp=head;
head=head->link;
delete temp;
}
temp=head=NULL;

cin.sync();
cin.get();
return 0;
}
void unos(node *&head)
{
int n;
node *curr,*temp;

do{
cout<<"Unesi broj. ";
cin>>n;
curr=new node;
curr->data=n;
curr->link=0;
if(head)
{
temp=head;
while(temp->link)
temp=temp->link;
temp->link=curr;
}
else
head=curr;
}while(n!=0);
}
void ispis(node *head)
{ while(head)
{
cout<data<<" ";
head=head->link;
}
}


Post je objavljen 04.06.2012. u 20:01 sati.