Contoh program sederhana Linked List

Sebelum memahami contoh program sederhana Linked List, Anda harus paham terlebih dahulu tentang Linked List. Jika sudah paham silahkan di simak source code contoh program sederhana Linked List dari saya ;) .
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <stdlib.h>

struct simpul
{
char nim[11];
char nama[35];
int smt;
struct simpul *next;
};
struct simpul *head = NULL;

main()
{
struct simpul *p;
struct simpul *curr;
clrscr();
p = (struct simpul *)malloc(sizeof(struct simpul));
strcpy(p->nim,"14.11.0095");
strcpy(p->nama,"FEGI T");
p->smt=2;
p->next=head;
head = p;

p = (struct simpul *)malloc(sizeof(struct simpul));
strcpy(p->nim, "14.11.0115");
strcpy(p->nama, "WIDIASTUTI");
p->smt=2;
p->next=head;
head = p;

curr=head;
while(curr)
{
cout<<"NIM : "<<curr->nim<<endl;
cout<<"Nama : "<<curr->nama<<endl;
cout<<"Semester : "<<curr->smt<<endl<<endl;
curr=curr->next;
}

getch();
}


Screenshoot output program

Contoh program sederhana Linked List

Related

Algoritma & Struktur Data 1192728660741282364

Post a Comment

emo-but-icon

Populer

Comments

Translate

Side Ads

item