Skip to content

Instantly share code, notes, and snippets.

@aldhinya
Created April 25, 2018 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aldhinya/0c86fe6db7d6d762b69c5c07dbf0ea15 to your computer and use it in GitHub Desktop.
Save aldhinya/0c86fe6db7d6d762b69c5c07dbf0ea15 to your computer and use it in GitHub Desktop.
Script Linked List C++
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
using namespace std;
struct simpul
{
int data;
simpul *next;
simpul *prev;
};
int main()
{
simpul *awal=NULL,*akhir=NULL,*baru,*bantu;
int input;
char ulang;
do
{
cout << "Isi Data = ";
if (awal==NULL)
{
cout << "Kosong";
}
else
{
bantu=awal;
while (bantu!=NULL)
{
cout <<bantu->data<< " ";
bantu=bantu->next;
}
}
cout << "\nMasukkan data = ";
cin>> input;
baru= new simpul;
baru->data= input;
baru->next= NULL;
baru->prev= NULL;
if (awal==NULL)
{
awal=baru;
akhir=baru;
}
else
{
akhir->next=baru;
baru->prev=akhir;
akhir=baru;
}
cout << "Ingin tambah lagi (y/t) = ";
cin >> ulang;
system("cls");
}
while (ulang=='Y' || ulang=='y');
}
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
using namespace std;
struct simpul
{
int data;
simpul *next;
simpul *akhir;
simpul *awal;
};
int main()
{
simpul *awal=NULL,*akhir=NULL,*baru,*bantu;
int data1;
char ulang;
do
{
cout << "Isi Data = ";
if (awal==NULL)
{
cout << "Kosong";
}
else
{
bantu=awal;
while (bantu!=NULL)
{
cout <<bantu->data<< " ";
bantu=bantu->next;
}
}
cout << "\nMasukkan data = ";
cin>> data1;
baru=new simpul;
baru->data=data1;
baru->next=NULL;
if (awal==NULL)
awal=baru;
else
akhir->next=baru;
akhir=baru;
cout << "Ingin tambah lagi (y/t) = ";
cin >> ulang;
system("cls");
}while (ulang=='Y' || ulang=='y');
}
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
using namespace std;
struct simpul
{
int data;
simpul *next;
simpul *prev;
};
int main()
{
simpul *awal=NULL,*akhir=NULL,*baru,*bantu;
int input;
char ulang;
do
{
cout << "Isi Data = ";
if (awal==NULL)
{
cout << "Kosong";
}
else
{
bantu=awal;
while (bantu!=NULL)
{
cout <<bantu->data<< " ";
bantu=bantu->next;
}
}
cout << "\nMasukkan data = ";
cin>> input;
baru= new simpul;
baru->data= input;
baru->next= NULL;
baru->prev= NULL;
if (awal==NULL)
{
awal=baru;
akhir=baru;
}
else
{
baru->next=awal;
awal->prev=baru;
awal=baru;
}
cout << "Ingin tambah lagi (y/t) = ";
cin >> ulang;
system("cls");
}
while (ulang=='Y' || ulang=='y');
}
#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <windows.h>
using namespace std;
struct simpul
{
int data;
simpul *next;
simpul *akhir;
simpul *awal;
};
int main()
{
simpul *awal=NULL,*akhir=NULL,*baru,*bantu;
int data1;
char ulang;
do
{
cout << "Isi Data = ";
if (awal==NULL)
{
cout << "Kosong";
}
else
{
bantu=awal;
while (bantu!=NULL)
{
cout <<bantu->data<< " ";
bantu=bantu->next;
}
}
cout << "\nMasukkan data = ";
cin>> data1;
baru=new simpul;
baru->data=data1;
baru->next=NULL;
if (awal==NULL)
akhir=baru;
else
baru->next=awal;
awal=baru;
cout << "Ingin tambah lagi (y/t) = ";
cin >> ulang;
system("cls");
}while (ulang=='Y' || ulang=='y');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment