Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sisip List
- #include <iostream>
- #include <stdlib.h>
- #include <malloc.h>
- using namespace std;
- typedef struct node{
- int data;
- struct node *next;
- } nod, *nodptr;
- void ngelist(nodptr *s){
- *s=NULL;
- }
- nodptr NodNew(int x){
- nodptr n;
- n=(nodptr) malloc
- (sizeof (nod));
- if(n!=NULL){
- n->data=x;
- n->next=NULL;
- }
- return n;
- }
- void sisiplist(nodptr *s, nodptr t, nodptr p){
- if(p==NULL){
- t->next=*s;
- *s=t;
- } else {
- t->next=p->next;
- p->next=t;
- }
- }
- void cetaklist(nodptr s){
- nodptr ps;
- for (ps=s; ps!=NULL; ps=ps->next){
- cout<<" "<<ps->data<<"-->"<<endl;
- }
- }
- int main(){
- nodptr pel;
- nodptr n;
- ngelist(&pel);
- n=NodNew(55);
- sisiplist(&pel,n,NULL);
- n=NodNew(75);
- sisiplist(&pel,n,NULL);
- n=NodNew(60);
- sisiplist(&pel,n,NULL);
- n=NodNew(20);
- sisiplist(&pel,n,NULL);
- n=NodNew(33);
- sisiplist(&pel,n,NULL);
- cetaklist(pel);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement