Created
April 25, 2018 15:02
-
-
Save aldhinya/0c86fe6db7d6d762b69c5c07dbf0ea15 to your computer and use it in GitHub Desktop.
Script Linked List C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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