Sabtu, 14 Januari 2012

Stuktur Data : Menggabungkan 2 Queen menjadi 1 !


Definisi Queue
Jika diartikan secara harafiah, queue berarti antrian, queue merupakan salah satu contoh aplikasi dari pembuatan double linked list yang cukup sering kita temui dalam kehiduypan sehari-hari, misalnya saat Anda mengantri di loket untuk membeli tiket. Istilah yang cukup sering dipakai seseorang masuk dalam sebuah antrian adalah enqueue. Dalam suatu antrian, yang dating terlebih dahulu akan dilayani lebih dahulu. Istilah yang sering dipakai bila seseorang keluar dari antrian adalah dequeue. Walaupun berbeda implementasi, struktur data queue setidaknya harus memiliki operasi-operasi sebagai berikut :
  • EnQueue Memasukkan data ke dalam antrian
  • DeQueue Mengeluarkan data terdepan dari antrian
  • Clear Menghapus seluruh antrian
  • IsEmpty Memeriksa apakah antrian kosong
  • IsFull Memeriksa apakah antrian penuh
Berikut ini adalah Implementasi Dalam C++
cekidot ^^
#include <iostream.h>
#include <conio.h>
#define maks 10

class queue{
      friend ostream& operator<<(ostream&, const queue&);
public:
       queue();
       int penuh(int);
       int kosong(int);
       void cetak();
       char enqueue(char);
       char dequeue();
       void bagi(queue &, queue&);
private:
        char A[maks];
        int banyak;};

ostream& operator<<(ostream& out, const queue& s){
         out<<"\nIsi Antrian : ";
         for(int i=0;i<s.banyak;i++)
         out<<s.A[i]<<" ";
         return out;}

queue::queue(){
               banyak=0;
               for(int i=0; i<maks; i++)
               A[i]='0';}

int queue::penuh(int s){
    return s==maks?1:0;}

int queue::kosong(int s){ 
    return s==0?1:0;}

void queue::cetak (){
     cout<<"\nIsi Antrian : ";
     for(int i=0;i<banyak;i++)
     cout<<A[i]<<" ";}

char queue::enqueue(char x){
     if (A[0]=='0'){
        A[0]=x;
        banyak++;}
     else{
          for (int i=banyak; i>=0; i--)
          A[i+1]=A[i];
          A[0]=x;
          banyak++;}}

char queue::dequeue(){
     char temp=A[--banyak];
     A[banyak]='0';
     return temp; }

void queue::bagi(queue &q1, queue &q2){
     char a[5],b[5];
     queue q3;
     cout<<"\n\nAntrian Gabungan";
     for(int i=0;i<5;i++){
     a[i]=q1.dequeue();
     q3.enqueue(a[i]);}
     for(int i=0;i<5;i++){
     b[i]=q2.dequeue();
     q3.enqueue(b[i]);}
     cout<<q3<<endl;}

int main(){
queue p,q,r;
char z[5] = {69,68,67,66,65};
char y[5] = {74,73,72,71,70};
cout<<"Antrian Pertama";
for(int i=5-1;i>=0;i--){
p.enqueue(z[i]);
cout<<p;}
cout<<"\n\nAntrian Kedua";
for(int j=5-1;j>=0;j--){
q.enqueue(y[j]);
cout<<q;}
r.bagi(p,q);
getch();
return 0;}

QUEUE (ANTREAN)

ANTREAN (Queue) 

Suatu bentuk khusus dari linear list, dengan operasi penyisipan (insertion) hanya diperbolehkan pada salah satu sisi, yang disebut REAR, dan operasi penghapusan (deletion) hanya diperbolehkan pada sisi yang lainnya, yang disebut FRONT dari list.

Antrean Q = [Q1, Q2, ... , QN]

  • Front(Q)        = Q1                  bagian depan antrean
  • Rear(Q)          = QN                 bagian belakang antrean
  • Noel(Q)          = N                    jumlah elemen dalam antrean

Operasi Antrean : FIFO (First In First Out)
Elemen yang pertama masuk merupakan elemen yang pertama keluar.

  • Operator :        Penyisipan         : Insert
                              Penghapusan     : Remove
Empat operasi dasar antrean, yaitu :
1.     CREATE 
2.     ISEMPTY 
3.     INSERT 
4.     REMOVE 

·            CREATE (Q)
Operator yang menunjukkan suatu antrean hampa Q.
Berarti :        Noel (Q) = 0
                    Front (Q) & Rear (Q) = tidak terdefinisi

·            ISEMPTY (Q)
Operator yang menunjukkan apakah antrean Q hampa.
Operand          : tipe data antrean
Hasil               : tipe data boolean

ISEMPTY (CREATE (Q)) = True

·            INSERT (E, Q)
Operator yang menginsert elemen E ke dalam antrean Q.
E ditempatkan di bagian belakang antrean.
Hasil : antrean yang lebih besar.

REAR (INSERT (E, Q)) = E
ISEMPTY (INSERT (E, Q)) = False
REMOVE (Q)
Operator yang menghapus elemen bagian depan dari antrean Q.
Hasil : antrean yang lebih pendek.
Pada setiap operasi, Noel (Q) berkurang 1 dan elemen ke-2 menjadi elemen terdepan.
Jika Noel (Q) = 0 maka Q = hampa
       Remove (Q) = kondisi error (underflow condition)
       Remove (Create (Q)) = kondisi error (underflow condition)

PENYAJIAN DARI ANTREAN
1. One Way List (Linear Linked List)
2. Array 

Array Queue
Kalau tidak disebutkan lain, maka Antrean disajikan dalam Array Queue, dilengkapi 2 variabel penunjuk : 
FRONT (elemen depan antrean)
REAR (elemen belakang antrean)


Program C++ : Binary Searh Tree (Pohon struktur data)

Dalam ilmu komputer, sebuah Pohon adalah suatu struktur data yang digunakan secara luas yang menyerupai struktur pohon dengan sejumlah simpul yang terhubung.
Dibawah ini adalah Implementasi dalam program c++ :


cekidot ^^

#include <iostream>
#include <cstdlib>
using namespace std;

class BinarySearchTree
{
    private:
        struct tree_node
        {
           tree_node* left;
           tree_node* right;
           int data;
        };
        tree_node* root;
    public:
        BinarySearchTree()
        {
           root = NULL;
        }
        bool isEmpty() const { return root==NULL; }
        void print_inorder();
        void inorder(tree_node*);
        void print_preorder();
        void preorder(tree_node*);
        void print_postorder();
        void postorder(tree_node*);
        void insert(int);
        void remove(int);
};

void BinarySearchTree::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)
    {
        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 BinarySearchTree::remove(int d)
{

    bool found = false;
    if(isEmpty())
    {
        cout<<" This Tree is empty! "<<endl;
        return;
    }
    tree_node* curr;
    tree_node* parent;
    curr = root;
    while(curr != NULL)
    {
         if(curr->data == d)
         {
            found = true;
            break;
         }
         else
         {
             parent = curr;
             if(d>curr->data) curr = curr->right;
             else curr = curr->left;
         }
    }
    if(!found)
         {
        cout<<" Data not found! "<<endl;
        return;
    }


    if((curr->left == NULL && curr->right != NULL)|| (curr->left != NULL
&& curr->right == NULL))
    {
       if(curr->left == NULL && curr->right != NULL)
       {
           if(parent->left == curr)
           {
             parent->left = curr->right;
             delete curr;
           }
           else
           {
             parent->right = curr->right;
             delete curr;
           }
       }
       else
       {
          if(parent->left == curr)
           {
             parent->left = curr->left;
             delete curr;
           }
           else
           {
             parent->right = curr->left;
             delete curr;
           }
       }
     return;
    }


         if( curr->left == NULL && curr->right == NULL)
    {
        if(parent->left == curr) parent->left = NULL;
        else parent->right = NULL;
                  delete curr;
                  return;
    }


    if (curr->left != NULL && curr->right != NULL)
    {
        tree_node* chkr;
        chkr = curr->right;
        if((chkr->left == NULL) && (chkr->right == NULL))
        {
            curr = chkr;
            delete chkr;
            curr->right = NULL;
        }
        else
        {

            if((curr->right)->left != NULL)
            {
                tree_node* lcurr;
                tree_node* lcurrp;
                lcurrp = curr->right;
                lcurr = (curr->right)->left;
                while(lcurr->left != NULL)
                {
                   lcurrp = lcurr;
                   lcurr = lcurr->left;
                }
                                    curr->data = lcurr->data;
                delete lcurr;
                lcurrp->left = NULL;
           }
           else
           {
               tree_node* tmp;
               tmp = curr->right;
               curr->data = tmp->data;
                              curr->right = tmp->right;
               delete tmp;
           }

        }
         return;
    }

}

void BinarySearchTree::print_inorder()
{
  inorder(root);
}

void BinarySearchTree::inorder(tree_node* p)
{
    if(p != NULL)
    {
        if(p->left) inorder(p->left);
        cout<<" "<<p->data<<" ";
        if(p->right) inorder(p->right);
    }
    else return;
}

void BinarySearchTree::print_preorder()
{
  preorder(root);
}

void BinarySearchTree::preorder(tree_node* p)
{
    if(p != NULL)
    {
        cout<<" "<<p->data<<" ";
        if(p->left) preorder(p->left);
        if(p->right) preorder(p->right);
    }
    else return;
}

void BinarySearchTree::print_postorder()
{
  postorder(root);
}

void BinarySearchTree::postorder(tree_node* p)
{
    if(p != NULL)
    {
        if(p->left) postorder(p->left);
        if(p->right) postorder(p->right);
        cout<<" "<<p->data<<" ";
    }
    else return;
}

int main()
{
    BinarySearchTree b;
    int n,ch,tmp,tmp1;
      cout<<"\tOperasi Pohon KHAIRUDIN \n\n";
    cout<<"Masukkan banyak data: ";
           cin>>n;
                    for (int i=0; i<=n; i++){
                    cout<<"Angka :";cin>>i;
                    b.insert(i);}
                 
                    cout<<"\n\nIn-Order Traversal "<<endl;
                    cout<<"-------------------"<<endl;
                    b.print_inorder();
                  
                    cout<<"\n\nPre-Order Traversal "<<endl;
                    cout<<"-------------------"<<endl;
                    b.print_preorder();
                
                    cout<<"\n\nPost-Order Traversal "<<endl;
                    cout<<"--------------------"<<endl;
                    b.print_postorder();
                    cout<<endl;
                 
           system("pause");
                    return 0;
                 
}



program C++ : implement AVL Tree & its Operations


#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#define FALSE 0
#define TRUE 1
struct AVLNode
{
 int data ;
 int balfact ;
 AVLNode *left ;
 AVLNode *right ;
} ;

class avltree
{
 private :
  AVLNode *root ;
 public :
  avltree( ) ;
  AVLNode*  insert ( int data, int *h ) ;
  static AVLNode* buildtree ( AVLNode *root, int data, int *h ) ;
  void display( AVLNode *root ) ;
  AVLNode* deldata ( AVLNode* root, int data, int *h ) ;
  static AVLNode* del ( AVLNode *node, AVLNode* root, int *h ) ;
  static AVLNode* balright ( AVLNode *root, int *h ) ;
  static AVLNode* balleft ( AVLNode* root, int *h ) ;
  void setroot ( AVLNode *avl ) ;
  ~avltree( ) ;
  static void deltree ( AVLNode *root ) ;
} ;
avltree::avltree( )
{
 root=NULL;
}
AVLNode* avltree::insert(int data, int *h )
{
 root = buildtree ( root, data, h ) ;
 return root ;
}
AVLNode* avltree :: buildtree ( AVLNode *root, int data, int *h )
{
 AVLNode *node1, *node2 ;

 if ( root == NULL )
 {
  root = new AVLNode ;
  root -> data = data ;
  root -> left = NULL ;
  root -> right = NULL ;
  root -> balfact = 0 ;
  *h = TRUE ;
  return ( root ) ;
 }
 if ( data < root -> data )
 {
  root -> left = buildtree ( root -> left, data, h ) ;

  // If left subtree is higher
  if ( *h )
  {
   switch ( root -> balfact )
   {
    case 1 :
     node1 = root -> left ;
     if ( node1 -> balfact == 1 )
     {
      cout << "\nRight rotation.\n" ;
      root -> left = node1 -> right ;
      node1 -> right = root ;
      root -> balfact = 0 ;
      root = node1 ;
     }
     else
     {
      cout << "\nDouble rotation, left then right." ;
      node2 = node1 -> right ;
      node1 -> right = node2 -> left ;
      node2 -> left = node1 ;
      root -> left = node2 -> right ;
      node2 -> right = root ;
      if ( node2 -> balfact == 1 )
       root -> balfact = -1 ;
      else
       root -> balfact = 0 ;
      if ( node2 -> balfact == -1 )
       node1 -> balfact = 1 ;
      else
       node1 -> balfact = 0 ;
      root = node2 ;
     }
     root -> balfact = 0 ;
     *h = FALSE ;
     break ;

    case 0 :
     root -> balfact = 1 ;
     break ;
    case -1 :
     root -> balfact = 0 ;
     *h = FALSE ;
   }
  }
 }

 if ( data > root -> data )
 {
  root -> right = buildtree ( root -> right, data, h ) ;

  if ( *h )
  {
   switch ( root -> balfact )
   {
    case 1 :
     root -> balfact = 0 ;
     *h = FALSE ;
     break ;
    case 0 :
     root -> balfact = -1 ;
     break ;
    case -1 :
     node1 = root -> right ;
     if ( node1 -> balfact == -1 )
     {
      cout << "\nLeft rotation.\n" ;
      root -> right = node1 -> left ;
      node1 -> left = root ;
      root -> balfact = 0 ;
      root = node1 ;
     }
     else
     {
      cout << "\nDouble rotation, right then left." ;
      node2 = node1 -> left ;
      node1 -> left = node2 -> right ;
      node2 -> right = node1 ;
      root -> right = node2 -> left ;
      node2 -> left = root ;
      if ( node2 -> balfact == -1 )
       root -> balfact = 1 ;
      else
       root -> balfact = 0 ;
      if ( node2 -> balfact == 1 )
       node1 -> balfact = -1 ;
      else
       node1 -> balfact = 0 ;
      root = node2 ;
     }
     root -> balfact = 0 ;
     *h = FALSE ;
   }
  }
 }
 return ( root ) ;
}
void avltree :: display ( AVLNode* root )
{
 if ( root != NULL )
 {
  display ( root -> left ) ;
  cout << root -> data << "\t" ;
  display ( root -> right ) ;
 }
}
AVLNode* avltree :: deldata ( AVLNode *root, int data, int *h )
{
 AVLNode *node ;
 if ( root -> data == 13 )
  cout << root -> data ;
 if ( root == NULL )
 {
  cout << "\nNo such data." ;
  return ( root ) ;
 }
 else
 {
  if ( data < root -> data )
  {
   root -> left = deldata ( root -> left, data, h ) ;
   if ( *h )
    root = balright ( root, h ) ;
  }
  else
  {
   if ( data > root -> data )
   {
    root -> right = deldata ( root -> right, data, h ) ;
    if ( *h )
     root = balleft ( root, h ) ;
   }
   else
   {
    node = root ;
    if ( node -> right == NULL )
    {
     root = node -> left ;
     *h = TRUE ;
     delete ( node ) ;
    }
    else
    {
     if ( node -> left == NULL )
     {
      root = node -> right ;
      *h = TRUE ;
      delete ( node ) ;
     }
     else
     {
      node -> right = del ( node -> right, node, h ) ;
      if ( *h )
       root = balleft ( root, h ) ;
     }
    }
   }
  }
 }
 return ( root ) ;
}
AVLNode* avltree :: del ( AVLNode *succ, AVLNode *node, int *h )
{
 AVLNode *temp = succ ;

 if ( succ -> left != NULL )
 {
  succ -> left = del ( succ -> left, node, h ) ;
  if ( *h )
   succ = balright ( succ, h ) ;
 }
 else
 {
  temp = succ ;
  node -> data = succ -> data ;
  succ = succ -> right ;
  delete ( temp ) ;
  *h = TRUE ;
 }
 return ( succ ) ;
}
AVLNode* avltree :: balright ( AVLNode *root, int *h )
{
 AVLNode *temp1, *temp2 ;
 switch ( root -> balfact )
 {
  case 1 :
   root -> balfact = 0 ;
   break ;
  case 0 :
   root -> balfact = -1 ;
   *h  = FALSE ;
   break ;
  case -1 :
   temp1 = root -> right ;
   if ( temp1 -> balfact <= 0 )
   {
    cout << "\nLeft rotation.\n";
    root -> right = temp1 -> left ;
    temp1 -> left = root ;
    if ( temp1 -> balfact == 0 )
    {
     root -> balfact = -1 ;
     temp1 -> balfact = 1 ;
     *h = FALSE ;
    }
    else
    {
     root -> balfact = temp1 -> balfact = 0 ;
    }
    root = temp1 ;
   }
   else
   {
    cout << "\nDouble rotation, right then left." ;
    temp2 = temp1 -> left ;
    temp1 -> left = temp2 -> right ;
    temp2 -> right = temp1 ;
    root -> right = temp2 -> left ;
    temp2 -> left = root ;
    if ( temp2 -> balfact == -1 )
     root -> balfact = 1 ;
    else
     root -> balfact = 0 ;
    if ( temp2 -> balfact == 1 )
     temp1 -> balfact = -1 ;
    else
     temp1 -> balfact = 0 ;
    root = temp2 ;
    temp2 -> balfact = 0 ;
   }
 }
 return ( root ) ;
}
AVLNode* avltree :: balleft ( AVLNode *root, int *h )
{
 AVLNode *temp1, *temp2 ;
 switch ( root -> balfact )
 {
  case -1 :
   root -> balfact = 0 ;
   break ;

  case 0 :
   root -> balfact = 1 ;
   *h = FALSE ;
   break ;

  case 1 :
   temp1 = root -> left ;
   if ( temp1 -> balfact >= 0 )
   {
    cout << "\nRight rotation." ;
    root -> left = temp1 -> right ;
    temp1 -> right = root ;

    if ( temp1 -> balfact == 0 )
    {
     root -> balfact = 1 ;
     temp1 -> balfact = -1 ;
     *h = FALSE ;
    }
    else
    {
     root -> balfact = temp1 -> balfact = 0 ;
    }
    root = temp1 ;
   }
   else
   {
    cout << "\nDouble rotation, left then right." ;
    temp2 = temp1 -> right ;
    temp1 -> right = temp2 -> left ;
    temp2 -> left = temp1 ;
    root -> left = temp2 -> right ;
    temp2 -> right = root ;
    if ( temp2 -> balfact == 1 )
     root -> balfact = -1 ;
    else
     root -> balfact = 0 ;
    if ( temp2-> balfact == -1 )
     temp1 -> balfact = 1 ;
    else
     temp1 -> balfact = 0 ;
    root = temp2 ;
    temp2 -> balfact = 0 ;
   }
 }
 return ( root ) ;
}
void avltree :: setroot ( AVLNode *avl )
{
 root = avl ;
}
avltree :: ~avltree( )
{
 deltree ( root ) ;
}


void avltree :: deltree ( AVLNode *root )
{
 if ( root != NULL )
 {
  deltree ( root -> left ) ;
  deltree ( root -> right ) ;
 }
 delete ( root ) ;
}
int main( )
{
 avltree at ;
 AVLNode *avl = NULL ;
 int h ;
 avl = at.insert(20,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(6,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(29,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(5,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(12,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(25,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(32,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(10,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(15,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(27,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(13,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl<<"\nAVL tree:\n";
 at.display(avl);
 avl = at.deldata(avl, 20, &h);
 at.setroot(avl);
 avl = at.deldata(avl, 12, &h);
 at.setroot(avl);
 cout<<"\n\npohon AVL setelah penghapusan 20 dan 12:\n" ;
 at.display(avl);
 cout<<endl;
 avl = at.insert(2,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(28,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(20,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.insert(8,&h);
 at.setroot(avl);
 at.display(avl);
 cout<<endl;
 avl = at.deldata(avl, 15, &h);
 at.setroot(avl);
 avl = at.deldata(avl, 6, &h);
 at.setroot(avl);
 avl = at.deldata(avl, 5, &h);
 at.setroot(avl);
 avl = at.deldata(avl, 13, &h);
 at.setroot(avl);
 avl = at.deldata(avl, 10, &h);
 at.setroot(avl);
 cout<<"\n\nPohon AVL setelah penghapusan 15,6,5,13 dan 10:\n" ;
 at.display(avl);
 cout<<endl<<endl;
 avl = at.insert(22,&h);
 at.setroot(avl);
 at.display(avl);
 avl = at.insert(23,&h);
 at.setroot(avl);
 cout<<"\n\nAVL Tree Akhir:\n";
 at.display(avl);
 getch();
}



SIAPAKAH HACKER DAN CRACKER ITU ? DAN APA PERBEDAANNYA ?

Selama ini kita kesulitan kan membedakan mana hacker dan mana cracker? Dan Siapakah hacker dan cracker itu sebenarnya? ini dia infonya.

(Inggris: hacker) adalah orang yang mempelajari, menganalisa, dan bisa memodifikasi atau bahkan mengeksploitasi sistem yang terdapat di sebuah perangkat seperti perangkat lunak komputer (program komputer) dan perangkat keras komputer, administrasi dan lainnya, terutama keamanan.

Selain itu, hacker juga sebutan untuk orang atau sekelompok orang yang memberikan sumbangan bermanfaat untuk dunia jaringan dan sistem operasi, membuat program bantuan untuk dunia jaringan dan komputer. Hacker juga bisa dikategorikan perkerjaan yang dilakukan untuk mencari kelemahan suatu sistem dan memberikan ide atau pendapat yang bisa memperbaiki kelemahan sistem yang ditemukannya.

Sedangkan cracker adalah sebutan untuk orang yang mencari kelemahan sistem dan memasukinya untuk kepentingan pribadi dan mencari keuntungan dari sistem yang dimasuki seperti : pencurian data, penghapusan, dan lainnya.

Terminologi hacker muncul pada awal tahun 1960-an di antara para anggota organisasi mahasiswa Tech Model Railroad Club di Laboratorium Kecerdasan Artifisial Massachusetts Institute of Technology (MIT). Kelompok mahasiswa tersebut merupakan salah satu perintis perkembangan teknologi komputer dan mereka berkutat dengan sejumlah komputer mainframe. Kata hacker pertama kalinya muncul dengan arti positif untuk menyebut seorang anggota yang memiliki keahlian dalam bidang komputer dan mampu membuat program komputer yang lebih baik ketimbang yang telah dirancang bersama.

Kemudian pada tahun 1983, istilah hacker berubah menjadi negatif. Pasalnya, pada tahun tersebut untuk pertamakalinya FBI menangkap kelompok kriminal komputer The 414s yang berbasis di Milwaukee AS. 414 adalah kode area lokal mereka. Kelompok yang kemudian disebut sebagai hacker tersebut dinyatakan bersalah atas pembobolan 60 buah komputer, dari komputer milik Pusat Kanker Memorian Solan-Kettering hingga komputer milik laboratorium Nasional Los Alamos. Satu dari pelakuk tersebut mendapat kekebalan karena testimonialnya, sedangkan 5 pelaku lainnya mendapat hukuman masa percobaan.

Hacker mempunyai konotasi negatif karena kesalahpahaman masyarakat dengan perbedaan istilah antara hacker dan cracker. Banyak orang memahami bahwa bahwa hacker yang mengakibatkan kerugian pihak tertentu, seperti menyisipkan kode virus dan mencuri sebuah data transaksi penting, dan lain sebagainya. Padahal mereka adalah cacker. Cracker menggunakan celah keamanan yang belum diperbaiki oleh pembuat perangkat lunak (bug) untuk menyusup dan merusak sebuah sistem. Atas alasan ini biasanya para hacker dipahami dibagi menjadi 2 golongan White Hat Hackers yakni hacker yang sebenarnya dan cracker yang sering disebut dengan istilah Black Hat Hackers.

Minggu, 24 April 2011

Contoh perulangan

  •  Perulangan pola naik : awal =1 , akhir = 4 , syarat akhir >= awal terpenuhi . Program mencetak bilangan 1 - 4.


for loop
while loop
do_while loop
#include <iostream.h>
main(){
int i;
for (i=1;i<=4;i++)
cout << “ ” <<i;
return 0;
}
#include <iostream.h>
main(){
int i=1;
while (i<=4){
cout<<” “ << i;
i++;
}
return 0;
}
#include <iostream.h>
main(){
int i=1;
do{cout<<” “<<i;
i++;
}while (i<=4);
return 0;
}

  •  Perulangan pola turun : awal =4 , akhir = 1 , syarat awal >= akhir terpenuhi . Program mencetak bilangan 4 - 1.


for loop
while loop
do_while loop
#include <iostream.h>
main(){
int i;
for (i=4;i>=1;i--)
cout << “ ” <<i;
return 0;
}
#include <iostream.h>
main(){
int i=4;
while (i>=4){
cout<<” “ << i;
i--;
}
return 0;
}
#include <iostream.h>
main(){
int i=1;
do{
cout<<” “<<i;
i--;
}while (i>=1);
return 0;
}