Selasa, 17 Juli 2012

TUGAS MODUL 6.1 LINKED LIST

input : 
//============================================================================
// Name        : 1_LinkedList.cpp
// Author      : agust
// Version     :
// Copyright   :
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
//#include <conio.h>
#include <malloc.h>
using namespace std;

int main()
{
int i;

struct ListEntry
{
int number;
struct ListEntry *next;
}   start, *node;

start.next=NULL;
node=&start;
for (i=1; i<=10; i++)
{
node->next=(struct ListEntry *) malloc(sizeof(struct ListEntry));
   node=node->next;
   node->number=i;
   node->next=NULL;
}

node=start.next;

while (node)
{
   cout<<node->number;
   node=node->next;
   }
return 0;
}

output :


Selasa, 05 Juni 2012

Senin, 04 Juni 2012

array nama dengan perintah (while) menggunakan eclipse

input :

#include <iostream>
using namespace std;

int main() {
int pilih;
int agus[8][32]=
{
{0,1,1,1,1,1,0,0, 0,1,1,1,1,1,0,0, 1,1,0,0,0,0,1,0, 0,1,1,1,1,1,1,0},
   {0,1,0,0,0,1,0,0, 1,1,0,0,0,1,1,0, 1,1,0,0,0,0,1,0, 1,1,0,0,0,0,0,0},
   {0,1,0,0,0,1,0,0, 1,1,0,0,0,0,0,0, 1,1,0,0,0,0,1,0, 1,1,0,0,0,0,0,0},
{1,1,1,1,1,1,1,0, 1,1,0,0,0,0,0,0, 1,1,0,0,0,0,1,0, 0,1,1,1,1,1,0,0},
{1,1,0,0,0,0,1,0, 1,1,0,0,0,1,1,0, 1,1,0,0,0,0,1,0, 0,0,0,0,0,1,1,0},
{1,1,0,0,0,0,1,0, 1,1,0,0,0,0,1,0, 1,1,1,1,1,1,1,0, 0,0,0,0,0,1,1,0},
{1,1,0,0,0,0,1,0, 0,1,1,1,1,1,1,0, 0,1,1,1,1,1,0,0, 1,1,1,1,1,1,0,0},
{0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0},
};
int a, s;
int agust [4][8][8]=
{
{{0,1,1,1,1,1,0,0},
{0,1,0,0,0,1,0,0},
{0,1,0,0,0,1,0,0},
{1,1,1,1,1,1,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{0,0,0,0,0,0,0,0}},

{{0,1,1,1,1,1,0,0},
{1,1,0,0,0,1,1,0},
{1,1,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{1,1,0,0,0,1,1,0},
{1,1,0,0,0,0,1,0},
{0,1,1,1,1,1,1,0},
{0,0,0,0,0,0,0,0}},

{{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,0,0},
{0,0,0,0,0,0,0,0}},

{{0,1,1,1,1,1,1,0},
{1,1,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{0,1,1,1,1,1,0,0},
{0,0,0,0,0,1,1,0},
{0,0,0,0,0,1,1,0},
{1,1,1,1,1,1,0,0},
{0,0,0,0,0,0,0,0}}
};
int h,i,j;

cout<<"pilihan";
cout<<"\n1 = Array 2D";
cout<<"\n2 = Array 3D";
cout<<"\n3 = Exit\n";
cout<<"Pilih Untuk Menampilkan Nama: ";
cin>>pilih;
cout<<endl;

while(1)
{
if(pilih==1){
for(a=0;a<8;a++)
{
for(s=0;s<32;s++)
if(agus[a][s]==1)
cout<<"0";
else
cout<<'\x20';
cout<<endl;
}
}
break;

}
while(1)
{
if(pilih==2){
for(h=0;h<4;h++)
{
for(i=0;i<8;i++)
{
for(j=0;j<8;j++)

if (agust [h] [i] [j]==1)
cout<<"0";
else
cout<<"\x20";
cout<<endl;
}
cout<<endl;
}

}
break;
}
while(1)
{
if(pilih==3)
{
cout<<"terimakasih menggunakan program ini!";
}
break;
}
return 0;
}

output :
saat memilih pilihan nomor 1 maka akan muncul :


jika memilih nomor 2 maka akan muncul :


jika memilih nomor 3 maka akan muncul :


silahkan dicoba semoga berhasil
GBU

array nama dengan perintah (case) menggunakan eclipse

input :

#include <iostream>
using namespace std;

int main() {
int pilih;
cout<<"pilihan array";
cout<<"\n1 = array 2D";
cout<<"\n2 = array 3D";
cout<<"\n3 = exit";
cout<<"\npilih : ";
cin>>pilih;
cout<<"\n";
switch (pilih)
{
case 1 :
{
int hrf[8][32]=
{
{0,1,1,1,1,1,0,0, 0,1,1,1,1,1,0,0, 1,1,0,0,0,0,1,0, 0,1,1,1,1,1,1,0},
   {0,1,0,0,0,1,0,0, 1,1,0,0,0,1,1,0, 1,1,0,0,0,0,1,0, 1,1,0,0,0,0,0,0},
   {0,1,0,0,0,1,0,0, 1,1,0,0,0,0,0,0, 1,1,0,0,0,0,1,0, 1,1,0,0,0,0,0,0},
{1,1,1,1,1,1,1,0, 1,1,0,0,0,0,0,0, 1,1,0,0,0,0,1,0, 0,1,1,1,1,1,0,0},
{1,1,0,0,0,0,1,0, 1,1,0,0,0,1,1,0, 1,1,0,0,0,0,1,0, 0,0,0,0,0,1,1,0},
{1,1,0,0,0,0,1,0, 1,1,0,0,0,0,1,0, 1,1,1,1,1,1,1,0, 0,0,0,0,0,1,1,0},
{1,1,0,0,0,0,1,0, 0,1,1,1,1,1,1,0, 0,1,1,1,1,1,0,0, 1,1,1,1,1,1,0,0},
{0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0},
};
 int i,j;
  for(i=0;i<8;i++)
  {
  for(j=0; j<32; j++)
  if (hrf[i][j]==1)
  cout<<"0";
  else
  cout<<"\x20";
  cout<<endl;
}
  return 0;
break;
}
case 2 :
{
int huruf[4][8][8]=
{
{{0,1,1,1,1,1,0,0},
{0,1,0,0,0,1,0,0},
{0,1,0,0,0,1,0,0},
{1,1,1,1,1,1,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{0,0,0,0,0,0,0,0}},

{{0,1,1,1,1,1,0,0},
{1,1,0,0,0,1,1,0},
{1,1,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{1,1,0,0,0,1,1,0},
{1,1,0,0,0,0,1,0},
{0,1,1,1,1,1,1,0},
{0,0,0,0,0,0,0,0}},

{{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,0,0,0,0,1,0},
{1,1,1,1,1,1,1,0},
{0,1,1,1,1,1,0,0},
{0,0,0,0,0,0,0,0}},

{{0,1,1,1,1,1,1,0},
{1,1,0,0,0,0,0,0},
{1,1,0,0,0,0,0,0},
{0,1,1,1,1,1,0,0},
{0,0,0,0,0,1,1,0},
{0,0,0,0,0,1,1,0},
{1,1,1,1,1,1,0,0},
{0,0,0,0,0,0,0,0}}

};

int i,j,k;
for(i=0;i<4;i++)
{
for(j=0;j<8;j++)
{
for(k=0;k<8;k++)
if(huruf[i][j][k]==1)
cout<<"0";
else
cout<<"\x20";
cout<<endl;
}
}
return 0;
break;
}
case 3 :
{
{
cout<<"terimakasih menggunakan program ini!";
}
return 0;
break;
}

return 0;
}
}

output :
saat memilih pilihan nomor 1 maka akan muncul :

dan jika input nomor 2 maka akan muncul :


input nomor 3 maka akan muncul :

silahkan di coba, semoga bermanfaat
GBU