#include <iostream.h>
#include <stdlib.h>
#include <malloc.h>
#include <conio.h>
#define Nil NULL
#define info (P) P ->info
#define next (P) P ->next
#define First (L) (L)
typedef int InfoType;
typedef struct telmlist *address;
typedef struct telmlist
{
InfoType info;
address next;
}elmtlist;
typedef address list;
void CiptaSenarai(list *L)
{
first (*L) =Nil;
}
list NodBaru(int m)
{
list n;
n= (list) malloc (sizeof (elmtlist));
if (n != Null)
{
info(n) = m;
next(n) = Nil;
}
return n;
}
void SisipSenarai (List *L,list t,list p)
{
if )p == Nil)
{
t->next = p->next;
p->next = t;
}
}
void CetakSenarai (list L)
{
list ps;
for (ps=L; ps!=Nil; ps=ps->next)
{
cout<<"NULL"<<endl;
}
int main()
{
list pel;
list n;
int i,k,nilai;
CiptaSenarai (&pel);
cout<<"Masukan Banyak Data =";
cin>>k;
for (i=1; i<=k; i++)
{
cout<<"Masukan Data Senarai ke-"<<i<<" =";
cin>>nilai;
n=Nodbaru (nilai);
SisipSenarai (&pel,n,NULL);
}
CetakSenarai(pel);
return 0;
}
#include <stdlib.h>
#include <malloc.h>
#include <conio.h>
#define Nil NULL
#define info (P) P ->info
#define next (P) P ->next
#define First (L) (L)
typedef int InfoType;
typedef struct telmlist *address;
typedef struct telmlist
{
InfoType info;
address next;
}elmtlist;
typedef address list;
void CiptaSenarai(list *L)
{
first (*L) =Nil;
}
list NodBaru(int m)
{
list n;
n= (list) malloc (sizeof (elmtlist));
if (n != Null)
{
info(n) = m;
next(n) = Nil;
}
return n;
}
void SisipSenarai (List *L,list t,list p)
{
if )p == Nil)
{
t->next = p->next;
p->next = t;
}
}
void CetakSenarai (list L)
{
list ps;
for (ps=L; ps!=Nil; ps=ps->next)
{
cout<<"NULL"<<endl;
}
int main()
{
list pel;
list n;
int i,k,nilai;
CiptaSenarai (&pel);
cout<<"Masukan Banyak Data =";
cin>>k;
for (i=1; i<=k; i++)
{
cout<<"Masukan Data Senarai ke-"<<i<<" =";
cin>>nilai;
n=Nodbaru (nilai);
SisipSenarai (&pel,n,NULL);
}
CetakSenarai(pel);
return 0;
}
ConversionConversion EmoticonEmoticon