Rabu, 25 Juli 2012
Menghitung Luas dan Keliling Bangun Datar dengan VB
Silahkan Download aplikasi ini dengan klik link dibawah ini :
http://www.mediafire.com/?rpd30oxphr1ybi3
Kalkulator Sederhana dengan VB
Untuk mendownload aplikasi kalkulator sederhana dengan VB ini silahkan download link dibawah ini :
http://www.mediafire.com/?3oe3adda8u81u6u
Senin, 04 Juni 2012
Sequintal Searching
#include "stdio.h"
#include "conio.h"
#include "iostream.h"
void main()
{
clrscr();
int data[8] = {8,10,6,-2,11,7,1,100};
int cari;
int flag=0;
cout<<"\n";
cout<<"\tSequential Searching \n";
cout<<"\t-------------------- \n\n";
printf(" Masukkan data yang ingin dicari = ");scanf("%d",&cari);
for(int i=0;i<8;i++)
{
if(data[i]==cari) flag=1;
}
if (flag==1) printf("\n\n Data Ada \n");
else printf("\n\n Data Tidak Ada\n");
getch();
}
Apabila ada kesalahan dalam diatas , Silahkan download yang ini :
http://www.mediafire.com/?435y8fnand22fdf
#include "conio.h"
#include "iostream.h"
void main()
{
clrscr();
int data[8] = {8,10,6,-2,11,7,1,100};
int cari;
int flag=0;
cout<<"\n";
cout<<"\tSequential Searching \n";
cout<<"\t-------------------- \n\n";
printf(" Masukkan data yang ingin dicari = ");scanf("%d",&cari);
for(int i=0;i<8;i++)
{
if(data[i]==cari) flag=1;
}
if (flag==1) printf("\n\n Data Ada \n");
else printf("\n\n Data Tidak Ada\n");
getch();
}
Apabila ada kesalahan dalam diatas , Silahkan download yang ini :
http://www.mediafire.com/?435y8fnand22fdf
Binary Searching
#include "stdio.h"
#include "conio.h"
#include "iostream.h"
#include "stdlib.h"
void main()
{
clrscr();
int data[9]= {3,9,11,12,15,17,23,31,35};
int l,r,m;
int n=9;
int cari=17;
cout<<"\n";
cout<<"\tBinary Searching \n";
cout<<"\t---------------- \n";
l=0;
r=n-1;
int ktm=0;
while(l<=r && ktm==0)
{ m=(l+r)/2;
printf("\n\tData Tengah %d \n",m);
if(data[m] == cari) ktm=1;
else if(cari < data[m])
{
printf("\n\tCari Dikiri \n");
r=m-1;
}
else
{ l=m+1;
printf("\n\tCari Dikanan \n");
}
}
if (ktm=1) printf("\n\n Data yang dicari sudah Ditemukan\n");
else printf("\n\n Data yang dicari Tidak Ditemukan\n");
getch();
}
Apabila ada kesalahan running , silahkan download disini :
http://www.mediafire.com/?jrsoknz1wx2wo4h
#include "conio.h"
#include "iostream.h"
#include "stdlib.h"
void main()
{
clrscr();
int data[9]= {3,9,11,12,15,17,23,31,35};
int l,r,m;
int n=9;
int cari=17;
cout<<"\n";
cout<<"\tBinary Searching \n";
cout<<"\t---------------- \n";
l=0;
r=n-1;
int ktm=0;
while(l<=r && ktm==0)
{ m=(l+r)/2;
printf("\n\tData Tengah %d \n",m);
if(data[m] == cari) ktm=1;
else if(cari < data[m])
{
printf("\n\tCari Dikiri \n");
r=m-1;
}
else
{ l=m+1;
printf("\n\tCari Dikanan \n");
}
}
if (ktm=1) printf("\n\n Data yang dicari sudah Ditemukan\n");
else printf("\n\n Data yang dicari Tidak Ditemukan\n");
getch();
}
Apabila ada kesalahan running , silahkan download disini :
http://www.mediafire.com/?jrsoknz1wx2wo4h
Kamis, 10 Mei 2012
Pohon Biner
#include "iostream.h"
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
struct tree_node
{
tree_node* left;
tree_node* right;
int data;
};
tree_node* root;
bool isEmpty()
{return root==NULL;}
void insert(int d)
{
tree_node* t = new tree_node;
tree_node* parent;
t->data = d;
t->left = NULL;
t->right = NULL;
parent = NULL;
if(isEmpty())root = t;
else
{
tree_node* curr;
curr = root;
while(curr!=NULL)
{
parent = curr;
if(t->data > curr->data) curr = curr->right;
else curr = curr->left;
}
if(t->data < parent->data)
parent->left = t;
else
parent->right = t;
}
}
void inorder(tree_node* p)
{
if(p!=NULL)
{
if(p->left)
inorder(p->left);
cout<<" "<data<<" ";
if(p->right)
inorder(p->right);
}
else
return;
}
void print_inorder()
{ inorder(root); }
void preorder(tree_node* p)
{
if(p!=NULL)
{
if(p->left)
preorder(p->left);
cout<<" "<data<<" ";
if(p->right)
preorder(p->right);
}
else
return;
}
void print_preorder()
{ preorder(root); }
void postorder(tree_node* p)
{
if(p!=NULL)
{
if(p->left)
postorder(p->left);
cout<<" "<data<<" ";
if(p->right)
postorder(p->right);
}
else
return;
}
void print_postorder()
{ postorder(root); }
int main()
{
root=NULL;
int ch,tmp;
while(1)
{
system("cls");
cout<<"\n Menu Utama Operasi Pohon Biner";
cout<<" -----------------------------";
cout<<" 1. Insert/Tambah Data";
cout<<" 2. Kunjungan In-Order";
cout<<" 3. Kunjungan Pre-Order";
cout<<" 4. Kunjungan Post-Order";
cout<<" 5. Exit";
cout<<" Pilihan Anda : ";cin>>ch;
switch(ch)
{
case 1 :
cout<<" Masukan Data : ";cin>>tmp;
insert(tmp);
break;
case 2 :
cout<<" Kunjungan In-Order";
cout<<" ------------------";
print_inorder();getch();
break;
case 3 :
cout<<" Kunjungan Pre-Order";
cout<<" -------------------";
print_preorder();getch();
break;
case 4 :
cout<<" Kunjungan Post-Order";
cout<<" --------------------";
print_postorder();getch();
break;
case 5 : return 0;
break;
default:
cout<<" Pilihan yang Anda Masukkan salah!";
getch();
break;
}
}
}
Apabila ada kesalah dalam running , silahkan downolad yang ini:
http://www.mediafire.com/?7iy971zw1hsec55 atau http://www.mediafire.com/?94ok2ts2l8m64ro
Maaf Link ini dicopas saja yaa buka di Tab baru :)
#include "stdio.h"
#include "conio.h"
#include "stdlib.h"
struct tree_node
{
tree_node* left;
tree_node* right;
int data;
};
tree_node* root;
bool isEmpty()
{return root==NULL;}
void insert(int d)
{
tree_node* t = new tree_node;
tree_node* parent;
t->data = d;
t->left = NULL;
t->right = NULL;
parent = NULL;
if(isEmpty())root = t;
else
{
tree_node* curr;
curr = root;
while(curr!=NULL)
{
parent = curr;
if(t->data > curr->data) curr = curr->right;
else curr = curr->left;
}
if(t->data < parent->data)
parent->left = t;
else
parent->right = t;
}
}
void inorder(tree_node* p)
{
if(p!=NULL)
{
if(p->left)
inorder(p->left);
cout<<" "<
if(p->right)
inorder(p->right);
}
else
return;
}
void print_inorder()
{ inorder(root); }
void preorder(tree_node* p)
{
if(p!=NULL)
{
if(p->left)
preorder(p->left);
cout<<" "<
if(p->right)
preorder(p->right);
}
else
return;
}
void print_preorder()
{ preorder(root); }
void postorder(tree_node* p)
{
if(p!=NULL)
{
if(p->left)
postorder(p->left);
cout<<" "<
if(p->right)
postorder(p->right);
}
else
return;
}
void print_postorder()
{ postorder(root); }
int main()
{
root=NULL;
int ch,tmp;
while(1)
{
system("cls");
cout<<"\n Menu Utama Operasi Pohon Biner";
cout<<" -----------------------------";
cout<<" 1. Insert/Tambah Data";
cout<<" 2. Kunjungan In-Order";
cout<<" 3. Kunjungan Pre-Order";
cout<<" 4. Kunjungan Post-Order";
cout<<" 5. Exit";
cout<<" Pilihan Anda : ";cin>>ch;
switch(ch)
{
case 1 :
cout<<" Masukan Data : ";cin>>tmp;
insert(tmp);
break;
case 2 :
cout<<" Kunjungan In-Order";
cout<<" ------------------";
print_inorder();getch();
break;
case 3 :
cout<<" Kunjungan Pre-Order";
cout<<" -------------------";
print_preorder();getch();
break;
case 4 :
cout<<" Kunjungan Post-Order";
cout<<" --------------------";
print_postorder();getch();
break;
case 5 : return 0;
break;
default:
cout<<" Pilihan yang Anda Masukkan salah!";
getch();
break;
}
}
}
http://www.mediafire.com/?7iy971zw1hsec55 atau http://www.mediafire.com/?94ok2ts2l8m64ro
Maaf Link ini dicopas saja yaa buka di Tab baru :)
Senin, 07 Mei 2012
Stack (Tumpukan)
#include "vector"
#include "stdio.h"
#include "conio.h"
#include "iostream.h"
#define MAX_STACK 6
typedef int itemType;
typedef struct {
int data[MAX_STACK];
int top;
} Stack;
void init(Stack *tumpuk){
tumpuk->top=-1;
}
int isempty(Stack *tumpuk){
return (tumpuk->top==-1);
}
int isfull(Stack *tumpuk){
return (tumpuk->top==MAX_STACK-1);
}
void Push(itemType x, Stack *tumpuk){
if(isfull(tumpuk))
printf("\n Data penuh\n");
else{
tumpuk->data[tumpuk->top]=x;
++(tumpuk->top);
printf("\n Data %i telah ditambah\n",x);
}
}
void Pop(Stack *tumpuk, itemType *x){
if(isempty(tumpuk))
printf("\n Data kosong\n");
else{
--(tumpuk->top);
*x=tumpuk->data[tumpuk->top];
tumpuk->data[tumpuk->top]=-1;
printf("\n Data %i telah dihapus\n",*x);
}
}
void tampil(Stack *tumpuk){
if(isempty(tumpuk))
printf("\n Data kosong\n");
else
for(int i=tumpuk->top-1;i>=-1;i--){
cout<<"\n Data ke-"<data[i];
}
}
void Clear(Stack *tumpuk){
tumpuk->top=-1;
printf("\n Semua data telah dihapus\n");
}
void main()
{
int pilih;
Stack tumpukan;
itemType data;
init(&tumpukan);
do{
printf("\n\n MENU:");
printf("\n 1. [PUSH] Menambah Data \n");
printf(" 2. [POP] Menghapus Data \n");
printf(" 3. [PRINT] Tampilkan Data\n");
printf(" 4. [CLEAR] Hapus Semua Data\n");
printf(" 5. [EXIT] Keluar dari Program\n");
printf("\n Masukkan pilihan: "); scanf("%i",&pilih);
switch(pilih){
case 1: printf("\n Masukkan data: "); scanf("%i",&data);
Push(data,&tumpukan);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
case 2: Pop(&tumpukan,&data);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
case 3: tampil(&tumpukan);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
case 4: Clear(&tumpukan);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
}
}while(pilih!=5);
clrscr();
getch();
}
Masih ada yang salahkah?
Donload ini http://www.mediafire.com/?03d19122k5tysh6 ( copas di Tab baru)
#include "stdio.h"
#include "conio.h"
#include "iostream.h"
#define MAX_STACK 6
typedef int itemType;
typedef struct {
int data[MAX_STACK];
int top;
} Stack;
void init(Stack *tumpuk){
tumpuk->top=-1;
}
int isempty(Stack *tumpuk){
return (tumpuk->top==-1);
}
int isfull(Stack *tumpuk){
return (tumpuk->top==MAX_STACK-1);
}
void Push(itemType x, Stack *tumpuk){
if(isfull(tumpuk))
printf("\n Data penuh\n");
else{
tumpuk->data[tumpuk->top]=x;
++(tumpuk->top);
printf("\n Data %i telah ditambah\n",x);
}
}
void Pop(Stack *tumpuk, itemType *x){
if(isempty(tumpuk))
printf("\n Data kosong\n");
else{
--(tumpuk->top);
*x=tumpuk->data[tumpuk->top];
tumpuk->data[tumpuk->top]=-1;
printf("\n Data %i telah dihapus\n",*x);
}
}
void tampil(Stack *tumpuk){
if(isempty(tumpuk))
printf("\n Data kosong\n");
else
for(int i=tumpuk->top-1;i>=-1;i--){
cout<<"\n Data ke-"<data[i];
}
}
void Clear(Stack *tumpuk){
tumpuk->top=-1;
printf("\n Semua data telah dihapus\n");
}
void main()
{
int pilih;
Stack tumpukan;
itemType data;
init(&tumpukan);
do{
printf("\n\n MENU:");
printf("\n 1. [PUSH] Menambah Data \n");
printf(" 2. [POP] Menghapus Data \n");
printf(" 3. [PRINT] Tampilkan Data\n");
printf(" 4. [CLEAR] Hapus Semua Data\n");
printf(" 5. [EXIT] Keluar dari Program\n");
printf("\n Masukkan pilihan: "); scanf("%i",&pilih);
switch(pilih){
case 1: printf("\n Masukkan data: "); scanf("%i",&data);
Push(data,&tumpukan);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
case 2: Pop(&tumpukan,&data);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
case 3: tampil(&tumpukan);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
case 4: Clear(&tumpukan);
cout<<"\n\n ";
system("PAUSE");
clrscr();
break;
}
}while(pilih!=5);
clrscr();
getch();
}
Masih ada yang salahkah?
Donload ini http://www.mediafire.com/?03d19122k5tysh6 ( copas di Tab baru)
Minggu, 06 Mei 2012
Queue ( Antrian )
#include "stdio.h"
#include "iostream.h"
#include "conio.h"
#include "vector"
#define MAX 6
int head=0,tail=-1,data[MAX];
void insert(int x)
{
tail=(tail+1)%MAX;
data[tail]=x;
}
int del()
{
int t=0;
if(tail<=-1)
cout<<"\n\n Antrian Kosong.\n\n";
else
{
t=data[head];
if(head!=tail)
head=(head+1)%MAX;
else
{
head=0;
tail=-1;
}
}
return t;
}
void display()
{
int i;
if(tail<=-1)
cout<<"\n\n Antrian Kosong\n\n";
else
{
cout<<"\n\n Daftar Antrian :\n\n";
for(i=head;i!=tail;i=(i+1)%MAX)
cout< cout< }
}
void clear()
{
int i=0;
if(tail<=-1)
cout<<"\n\n Antrian Kosong\n\n";
else
for(i=head;i<=tail;i=(head+1)%MAX)
del();
if(i!=0)
cout<<"\n\n Antrian sudah dikosongkan\n\n";
}
void main()
{
int pilih,in,d;
clrscr();
do {
system("PAUSE");
clrscr();
cout<<"\n\n Menu:";
cout<<"\n 1. Menambah Antrian dibelakang (QUEUE)";
cout<<"\n 2. Mengurangi Antrian paling depan (DEQUEUE)";
cout<<"\n 3. Tampilkan Antrian";
cout<<"\n 4. Hapus Semua Antrian";
cout<<"\n 5. Keluar";
cout<<"\n\n Masukkan pilihan : ";
cin>>pilih;
switch(pilih)
{
case 1:
if(head==(tail+1)%MAX && tail>=MAX-1)
cout<<"\n\n Antrian sudah penuh\n\n";
else
{
cout<<"\n\n Tambahkan Antrian dibelakang : ";
cin>>in;
insert(in);
cout<<"\n";
system("PAUSE");
clrscr();
}
break;
case 2:
d=del();
if(d!=0)
cout<<"\n Kurangi Antrian paling depan : "< system("PAUSE");
clrscr();
break;
case 3:
display();
system("PAUSE");
clrscr();
break;
case 4:
clear();
system("PAUSE");
clrscr();
break;
case 5:
break;
default:clrscr();
cout<<"\n\n Pilihan Salah ! Silahkan ulangi kembali.\n\n";
}
}
while(pilih!=5);
}
Apabila ada kesalahan dalam running , silahkan download yang ini : http://www.mediafire.com/?zicp50d6i3p5n3h http://www.mediafire.com/?zicp50d6i3p5n3h
#include "iostream.h"
#include "conio.h"
#include "vector"
#define MAX 6
int head=0,tail=-1,data[MAX];
void insert(int x)
{
tail=(tail+1)%MAX;
data[tail]=x;
}
int del()
{
int t=0;
if(tail<=-1)
cout<<"\n\n Antrian Kosong.\n\n";
else
{
t=data[head];
if(head!=tail)
head=(head+1)%MAX;
else
{
head=0;
tail=-1;
}
}
return t;
}
void display()
{
int i;
if(tail<=-1)
cout<<"\n\n Antrian Kosong\n\n";
else
{
cout<<"\n\n Daftar Antrian :\n\n";
for(i=head;i!=tail;i=(i+1)%MAX)
cout< cout< }
}
void clear()
{
int i=0;
if(tail<=-1)
cout<<"\n\n Antrian Kosong\n\n";
else
for(i=head;i<=tail;i=(head+1)%MAX)
del();
if(i!=0)
cout<<"\n\n Antrian sudah dikosongkan\n\n";
}
void main()
{
int pilih,in,d;
clrscr();
do {
system("PAUSE");
clrscr();
cout<<"\n\n Menu:";
cout<<"\n 1. Menambah Antrian dibelakang (QUEUE)";
cout<<"\n 2. Mengurangi Antrian paling depan (DEQUEUE)";
cout<<"\n 3. Tampilkan Antrian";
cout<<"\n 4. Hapus Semua Antrian";
cout<<"\n 5. Keluar";
cout<<"\n\n Masukkan pilihan : ";
cin>>pilih;
switch(pilih)
{
case 1:
if(head==(tail+1)%MAX && tail>=MAX-1)
cout<<"\n\n Antrian sudah penuh\n\n";
else
{
cout<<"\n\n Tambahkan Antrian dibelakang : ";
cin>>in;
insert(in);
cout<<"\n";
system("PAUSE");
clrscr();
}
break;
case 2:
d=del();
if(d!=0)
cout<<"\n Kurangi Antrian paling depan : "<
clrscr();
break;
case 3:
display();
system("PAUSE");
clrscr();
break;
case 4:
clear();
system("PAUSE");
clrscr();
break;
case 5:
break;
default:clrscr();
cout<<"\n\n Pilihan Salah ! Silahkan ulangi kembali.\n\n";
}
}
while(pilih!=5);
}
Linked list
#include"stdio.h"
#include"conio.h"
#include"stdlib.h"
#include"iostream.h"
#include"iomanip.h"
//-----------------------------pembentukan simpul-----------------------------//
typedef struct TNode
{
int data;
TNode *next;
TNode *prev;
} TNode;
TNode *head;
void init();
int IsEmpty();
void InsertDepan(int);
void InsertBelakang(int);
void HapusDepan();
void HapusBelakang();
void clear();
void tampil();
//----------------------------looping program utama---------------------------//
void main()
{
int data;
int pil;
do{
printf("Double Linked List Circular \n");
cout< printf("1. Insert Depan\n");
printf("2. Insert Belakang\n");
printf("3. Hapus Depan\n");
printf("4. Hapus Belakang\n");
cout< printf("Masukkan Pilihan Anda(1-4): ");
scanf("%d",&pil);
clrscr();
switch(pil)
{
case 1:printf("Masukkan Data di Depan : ");scanf("%d",&data);
InsertDepan(data);break;
case 2:printf("Masukkan Data di Belakang : ");scanf("%d",&data);
InsertBelakang(data);break;
case 3:"%d",HapusDepan();break;
case 4:"%d",HapusBelakang();break;
;
}
getch();
}
while(pil!=7);
}
//------------------------------inisialisasi----------------------------------//
void init()
{ head = NULL;}
//-------------------------------pengecekan kondisi---------------------------//
int IsEmpty()
{
if(head==NULL)
return 1;
else
return 0;}
//----------------------------penambahan di depan-----------------------------//
void InsertDepan(int value)
{
TNode *bantu, *baru;
baru=new TNode;
baru ->data=value;
baru ->next=baru;
baru ->prev=baru;
if(IsEmpty()==1)
{
head=baru;
head ->next=head;
head ->prev=head;
}
else
{
bantu=head ->prev;
baru ->next=head;
head ->prev=baru;
head=baru;
head ->prev=bantu;
bantu ->next=head;
} cout< printf("Data Masuk \n"); }
//-----------------------------penambahan data dibelakang---------------------//
void InsertBelakang(int value)
{
TNode *baru, *bantu;
baru=new TNode;
baru ->data=value;
baru ->next=baru;
baru ->prev=baru;
if(IsEmpty()==1)
{
head=baru;
head ->next=head;
head ->prev=head;
}
else
{
bantu=head ->prev;
bantu ->next=baru;
baru ->prev=bantu;
baru ->next=head;
head ->prev=baru;
}
cout< printf("Data Masuk \n");
}
//------------------------------Hapus Depan-----------------------------------//
void HapusDepan()
{
TNode *hapus, *bantu;
int d;
if(IsEmpty()==0)
{
if(head ->next !=head)
{
hapus=head;
d=hapus ->data;
bantu=head ->prev;
head=head ->next;
bantu ->next=head;
head ->prev=bantu;
delete hapus;
}
else
{
d=head ->data;
head=NULL; }
cout< printf("%d Terhapus \n",d);
}
else
cout< printf("Masih Kosong \n");}
//------------------------Menghapus Data Dari Belakang------------------------//
void HapusBelakang()
{ TNode *hapus, *bantu;
int d;
if(IsEmpty()==0)
{
if(head ->next !=head)
{
bantu=head;
while(bantu->next->next !=head)
{ bantu=bantu ->next; }
hapus=bantu ->next;
d=hapus ->data;
bantu->next=head;
delete hapus;
}
else
{
d=head->data;
head=NULL;
}
printf("%d Terhapus \n",d);}
else
printf("Masih Kosong");
}
//------------------------------Menghapus Semua Data--------------------------//
void clear()
{
TNode *bantu, *hapus;
bantu=head;
if(IsEmpty()==0)
{
bantu=head;
while(bantu ->next!=head)
{ hapus=bantu;
bantu=bantu->next;
delete hapus;
}
head=NULL;
}
}
//-------------------------Tampilkan Data-------------------------------------//
void tampil()
{
TNode *bantu;
bantu=head;
if(IsEmpty()==0)
{
do
{
printf(" %d",bantu ->data);
bantu=bantu->next;
}
while(bantu !=head);
printf("\n");
}
else
printf("Data Kosong");
}
Masih ada yang salah silahkan donload ini : http://www.mediafire.com/?9asfo6bt6zhitsi http://www.mediafire.com/?9asfo6bt6zhitsi
#include"conio.h"
#include"stdlib.h"
#include"iostream.h"
#include"iomanip.h"
//-----------------------------pembentukan simpul-----------------------------//
typedef struct TNode
{
int data;
TNode *next;
TNode *prev;
} TNode;
TNode *head;
void init();
int IsEmpty();
void InsertDepan(int);
void InsertBelakang(int);
void HapusDepan();
void HapusBelakang();
void clear();
void tampil();
//----------------------------looping program utama---------------------------//
void main()
{
int data;
int pil;
do{
printf("Double Linked List Circular \n");
cout<
printf("2. Insert Belakang\n");
printf("3. Hapus Depan\n");
printf("4. Hapus Belakang\n");
cout<
scanf("%d",&pil);
clrscr();
switch(pil)
{
case 1:printf("Masukkan Data di Depan : ");scanf("%d",&data);
InsertDepan(data);break;
case 2:printf("Masukkan Data di Belakang : ");scanf("%d",&data);
InsertBelakang(data);break;
case 3:"%d",HapusDepan();break;
case 4:"%d",HapusBelakang();break;
;
}
getch();
}
while(pil!=7);
}
//------------------------------inisialisasi----------------------------------//
void init()
{ head = NULL;}
//-------------------------------pengecekan kondisi---------------------------//
int IsEmpty()
{
if(head==NULL)
return 1;
else
return 0;}
//----------------------------penambahan di depan-----------------------------//
void InsertDepan(int value)
{
TNode *bantu, *baru;
baru=new TNode;
baru ->data=value;
baru ->next=baru;
baru ->prev=baru;
if(IsEmpty()==1)
{
head=baru;
head ->next=head;
head ->prev=head;
}
else
{
bantu=head ->prev;
baru ->next=head;
head ->prev=baru;
head=baru;
head ->prev=bantu;
bantu ->next=head;
} cout<
//-----------------------------penambahan data dibelakang---------------------//
void InsertBelakang(int value)
{
TNode *baru, *bantu;
baru=new TNode;
baru ->data=value;
baru ->next=baru;
baru ->prev=baru;
if(IsEmpty()==1)
{
head=baru;
head ->next=head;
head ->prev=head;
}
else
{
bantu=head ->prev;
bantu ->next=baru;
baru ->prev=bantu;
baru ->next=head;
head ->prev=baru;
}
cout<
}
//------------------------------Hapus Depan-----------------------------------//
void HapusDepan()
{
TNode *hapus, *bantu;
int d;
if(IsEmpty()==0)
{
if(head ->next !=head)
{
hapus=head;
d=hapus ->data;
bantu=head ->prev;
head=head ->next;
bantu ->next=head;
head ->prev=bantu;
delete hapus;
}
else
{
d=head ->data;
head=NULL; }
cout<
}
else
cout<
//------------------------Menghapus Data Dari Belakang------------------------//
void HapusBelakang()
{ TNode *hapus, *bantu;
int d;
if(IsEmpty()==0)
{
if(head ->next !=head)
{
bantu=head;
while(bantu->next->next !=head)
{ bantu=bantu ->next; }
hapus=bantu ->next;
d=hapus ->data;
bantu->next=head;
delete hapus;
}
else
{
d=head->data;
head=NULL;
}
printf("%d Terhapus \n",d);}
else
printf("Masih Kosong");
}
//------------------------------Menghapus Semua Data--------------------------//
void clear()
{
TNode *bantu, *hapus;
bantu=head;
if(IsEmpty()==0)
{
bantu=head;
while(bantu ->next!=head)
{ hapus=bantu;
bantu=bantu->next;
delete hapus;
}
head=NULL;
}
}
//-------------------------Tampilkan Data-------------------------------------//
void tampil()
{
TNode *bantu;
bantu=head;
if(IsEmpty()==0)
{
do
{
printf(" %d",bantu ->data);
bantu=bantu->next;
}
while(bantu !=head);
printf("\n");
}
else
printf("Data Kosong");
}
Kamis, 01 Maret 2012
Toko Kelontong Keroncongan
#include <conio.h>
#include <stdio.h>
#include <iostream.h>
#include <iomanip.h>
main()
{
int jumbay, jumbel, harga, bayar, kembali=0;
char kode, merk[15], ukuran, nama[20], ket[10];
cout<<" TOKO KELONTONG KERONCONGAN "<<endl;
cout<<"------------------------------------------------------------\n"<<endl;
cout<<"A. Susu Dancow B. Susu Bendera C. Susu SGM"<<endl;
cout<<" 1. Ukuran Kecil 1. Ukuran Kecil 1. Ukuran Kecil"<<endl;
cout<<" 2. Ukuran Sedang 2. Ukuran Sedang 2. Ukuran Sedang "<<endl;
cout<<" 3. Ukuran Besar 3. Ukuran Besar 3. Ukuran Besar "<<endl;
cout<<endl;
cout<<"Masukkan Nama Pembeli : ";cin>>nama;
cout<<"Masukkan Kode Susu [A/B/C] : ";cin>>kode;
cout<<"Masukkan Ukuran Kaleng [K/S/B] : ";cin>>ukuran;
if (kode=='A' || kode=='a')
{
strcpy (merk, "Susu Dancow") ;
if (ukuran=='K' || ukuran=='k')
{strcpy(ket,"Kecil");
harga=25000;}
else if (ukuran=='S' || ukuran=='s')
{strcpy(ket,"Sedang");
harga=20000;}
else
{strcpy(ket,"Besar");
harga=15000;}
}
else if (kode=='B' || kode=='b' )
{
strcpy (merk, "Susu Bendera") ;
if (ukuran=='K' || ukuran=='k')
{strcpy(ket,"Kecil");
harga=20000;}
else if (ukuran=='S' || ukuran=='s')
{strcpy(ket,"Sedang");
harga=17500;}
else
{strcpy(ket,"Besar");
harga=13500;}
}
else if (kode=='C' || kode=='c' )
{
strcpy (merk, "Susu SGM") ;
if (ukuran=='K' || ukuran=='k')
{strcpy(ket,"Kecil");
harga=22000;}
else if (ukuran=='S' || ukuran=='s')
{strcpy(ket,"Sedang");
harga=16500;}
else
{strcpy(ket,"Besar");
harga=15000;}
}
cout<<"Jumlah yang Dibeli : ";cin>>jumbel;
clrscr();
jumbay=harga*jumbel;
kembali=bayar-jumbay;
cout<<" TOKO KELONTONG KERONCONGAN "<<endl;
cout<<"---------------------------------------------------\n"<<endl;
cout<<"Nama Pembeli : "<<nama<<endl;
cout<<"Merk Susu : "<<merk<<endl;
cout<<"Ukuran Kaleng : "<<ket<<endl;
cout<<"Harga Satuan Barang Rp. "<<harga<<endl;
cout<<"Jumlah Beli Susu : "<<jumbel<<endl;
cout<<"Harga yang Harus Dibayar Rp. "<<jumbay<<endl;
cout<<"---------------------------------------------------\n"<<endl;
cout<<" TERIMA KASIH "<<endl;
getch();
}
Check result Outputnya :
#include <stdio.h>
#include <iostream.h>
#include <iomanip.h>
main()
{
int jumbay, jumbel, harga, bayar, kembali=0;
char kode, merk[15], ukuran, nama[20], ket[10];
cout<<" TOKO KELONTONG KERONCONGAN "<<endl;
cout<<"------------------------------------------------------------\n"<<endl;
cout<<"A. Susu Dancow B. Susu Bendera C. Susu SGM"<<endl;
cout<<" 1. Ukuran Kecil 1. Ukuran Kecil 1. Ukuran Kecil"<<endl;
cout<<" 2. Ukuran Sedang 2. Ukuran Sedang 2. Ukuran Sedang "<<endl;
cout<<" 3. Ukuran Besar 3. Ukuran Besar 3. Ukuran Besar "<<endl;
cout<<endl;
cout<<"Masukkan Nama Pembeli : ";cin>>nama;
cout<<"Masukkan Kode Susu [A/B/C] : ";cin>>kode;
cout<<"Masukkan Ukuran Kaleng [K/S/B] : ";cin>>ukuran;
if (kode=='A' || kode=='a')
{
strcpy (merk, "Susu Dancow") ;
if (ukuran=='K' || ukuran=='k')
{strcpy(ket,"Kecil");
harga=25000;}
else if (ukuran=='S' || ukuran=='s')
{strcpy(ket,"Sedang");
harga=20000;}
else
{strcpy(ket,"Besar");
harga=15000;}
}
else if (kode=='B' || kode=='b' )
{
strcpy (merk, "Susu Bendera") ;
if (ukuran=='K' || ukuran=='k')
{strcpy(ket,"Kecil");
harga=20000;}
else if (ukuran=='S' || ukuran=='s')
{strcpy(ket,"Sedang");
harga=17500;}
else
{strcpy(ket,"Besar");
harga=13500;}
}
else if (kode=='C' || kode=='c' )
{
strcpy (merk, "Susu SGM") ;
if (ukuran=='K' || ukuran=='k')
{strcpy(ket,"Kecil");
harga=22000;}
else if (ukuran=='S' || ukuran=='s')
{strcpy(ket,"Sedang");
harga=16500;}
else
{strcpy(ket,"Besar");
harga=15000;}
}
cout<<"Jumlah yang Dibeli : ";cin>>jumbel;
clrscr();
jumbay=harga*jumbel;
kembali=bayar-jumbay;
cout<<" TOKO KELONTONG KERONCONGAN "<<endl;
cout<<"---------------------------------------------------\n"<<endl;
cout<<"Nama Pembeli : "<<nama<<endl;
cout<<"Merk Susu : "<<merk<<endl;
cout<<"Ukuran Kaleng : "<<ket<<endl;
cout<<"Harga Satuan Barang Rp. "<<harga<<endl;
cout<<"Jumlah Beli Susu : "<<jumbel<<endl;
cout<<"Harga yang Harus Dibayar Rp. "<<jumbay<<endl;
cout<<"---------------------------------------------------\n"<<endl;
cout<<" TERIMA KASIH "<<endl;
getch();
}
Check result Outputnya :
Langganan:
Postingan (Atom)