- Code: Select all
#include <iostream.h>
#include <conio.h>
#include <cstring.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct tipeS{
struct tipeS *Left;
int INFO;
struct tipeS *Right;
};
typedef struct tipeS simpul;
simpul *P,*FIRST,*LAST,*PVertex,*PEdge,*Q,*R,*S;
simpul *PointS[5];
void main() {
int A[5][5] = {0,5,0,9,0,
0,0,11,0,7,
7,0,0,9,0,
0,0,12,0,0,
11,0,5,0,0};
char NmS[5] = "ABCDE";
int I,J;
I=0;J=0;
P=new simpul;
P->INFO = NmS[0];
FIRST = P;
LAST = P;
P->Left = NULL;
P->Right = NULL;
PointS[0] = P;
printf("%c", P-> INFO);
printf(" alamat %d \n", PointS[0]);
for (I=1;I<=4;I++)
{P = new simpul;
P->INFO = NmS[I];
LAST->Left = P;
LAST = LAST->Left;
P->Left = NULL;
P->Right = NULL;
PointS[I] = P;
printf("\n%c ", P->INFO);
printf("alamat %d \n", PointS[I]);
}
Q = FIRST;
for (I=0;I<=4;I++)
{R=Q;
printf("Vertex %c... ", Q->INFO);
for (J=0;J<=4;J++)
{ if(A[I][J]!=0)
{
P = new simpul;
P->INFO = A[I][J];
R->Right = P;
P->Left = PointS[J];
printf("berhubungan dengan %c: ", P->Left->INFO);
printf("bobot %d;", P->INFO);
P->Right = NULL;
R = P;
}
}
printf("\n");
Q = Q->Left;
}
}


emang yang nggak dipahami bagian yang mana, oom?






klo males google ya tanya ke i-bego.. tapi tetap beli kaos dulu






