Tuesday, December 05, 2017

Sorting with Buble sort at Pascal

Sorting with Buble sort became famous when applied in algorithm and programming especially for informatics university students. well.. here is the code that built in Pascal language..alhamdulillah..although I coded so many error, finally it done..

 program sorting_bubleSortV1;
 uses crt;
   const Nmaks = 100;
   type arrayInt = array[1..Nmaks] of integer;
   var
     {u : arrayInt;}
     n : integer;
     {maks : integer;}
     l : arrayint;



  procedure bacalarik(var l : arrayInt; n : integer);
  var
    k : integer;
  begin
    for k := 1 to n do
    begin
      write('masukan nilai : ');
      readln(l[k]);
    end;
  end;

  procedure urutgelombang1(var l : arrayInt; n : integer);
  var
    i : integer;
    k : integer;
    temp : integer;
  begin
    for i := 1 to n - 1 do
      for k := n DOWNTO i + 1 do
        if l[k] < l[k+1] then
        begin
          temp := l[k];
          l[k] := l[k-1];
          l[k-1] := temp;
        end;
   end;


  procedure tampillarik(var l : arrayInt; n : integer);
  var
    k : integer;
  begin
    for k := 1 to n do
    begin
      writeln('Nilai setelah disorting adalah : ',l[k]);
    end;
  end;

would Read More..!

Wednesday, November 22, 2017

Quee

What is Quee? for you who study in Informatics Engineering, Computer Sciency must have known about Quee, mustn't you. Ya.., Quee menggunakan konsep antrian FIFO (Fisrt in First Out), contoh real is easy..lihat antrian pembelian tiket kereta api yang manual ya..itu konsep Quee. Berikut diberikan contoh implementasi program Quee di C++ dengan method untuk AddQuee, DeleteQuee, DisplayElement, DisplayHeadTail. Materi lengkapnya sudah ane share buat para mahasiswa karyawan ya..coba di learnt, and discuss dipertemuan berikutnya jika ada yang didiskusikan, Now..here is the code please code manually, don't copy and paste :) to make us more understand about the code.

#include <iostream>

using namespace std;
struct node{
  int data;
  node *next;
};

class Queue{
  private:
    node *head;
    node *tail;
  public:
    Queue();

  void AddQueue(int i);
  void DelQueue();
  void CetakElement();
  void CetakHeadTail();
};

Queue::Queue()
{
  head = NULL;
  tail = NULL;
}
void Queue::AddQueue(int i)
{
  node *temp;
  temp = new node;
  temp->data = i;
  temp->next = NULL;
if( head == NULL)
{
  head = temp;
  tail = temp;
}
else{
  tail->next = temp;
  tail= temp;
  }
}

void Queue::DelQueue()
{
  node *temp;
  if(head != NULL)
{
  temp = head;
  head = head->next;
  delete temp;
  cout<<"Head di remove";
}
else
{
  cout<<"Queue Kosong"<<endl;
  }
}


would Read More..!

Wednesday, October 18, 2017

Quizes..

here is the link for "Algorithm and Programming 1" quiz_AlgoritmaPemrograman
and, here also the link for "Data Structure quize" quiz_StrukturData

would Read More..!

Thursday, October 05, 2017

eCommerce

Here is the link...
EBusiness_and_eCommerce

would Read More..!

Wednesday, October 04, 2017

Single Linked List examples

Berikut adalah contoh program Single Linked dengan satu simpul :
--------------------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

struct simpulNegara
{
    string nama;
    simpulNegara* berikut;
};

simpulNegara* buatSimpul(string negara)
{
    simpulNegara* pnegara;
   
    pnegara = new (simpulNegara);
    if (pnegara == NULL)
    {
        cout << "Pengalokasian " << negara
             << "gagal dilaksanakan." << endl;
       
        exit(1); //akhir program
    }
   
    //Isi simpul
    pnegara->nama = negara;
    pnegara->berikut = NULL;
   
    return pnegara;
}

int main()
{
    simpulNegara* pertama;
   
    pertama = buatSimpul("Swedia");
    cout << "Field nama : " << pertama->nama << endl;
    cout << "Isi berikut ";
   
    if (pertama->berikut == NULL)
       cout << "NULL" << endl;
    else
        cout << "TIDAK NULL" << endl;
   
    //Bebaskan memori untuk variabel dinamis
    delete pertama;
   
    return 0;
}
-------------------------------------------------------------------------------------------------------------------
Berikut adalah contoh program Single Linked dengan tiga simpul :
-------------------------------------------------------------------------------------------------------------------
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

struct simpulNegara
{
    string nama;
    simpulNegara* berikut;
};

simpulNegara* buatSimpul(string negara)
{
    simpulNegara* pnegara;

    pnegara = new (simpulNegara);
    if (pnegara == NULL)
    {
        cout << "Pengalokasian " << negara
             << "gagal dilaksanakan." << endl;

        exit(1); //akhir program
    }

    //Isi simpul
    pnegara->nama = negara;
    pnegara->berikut = NULL;

    return pnegara;
}

int main()
{
    simpulNegara* ptrBaru;
    simpulNegara* pertama;

    //Buat tiga variabel dinamis
    pertama = buatSimpul("Swedia");

    ptrBaru = buatSimpul("Jepang");
    ptrBaru->berikut = pertama;
    pertama = ptrBaru;

    ptrBaru = buatSimpul("India");
    ptrBaru->berikut = pertama;
    pertama = ptrBaru;

    //Tampilkan isi senarai berantai
    simpulNegara* ptr = pertama;
    while (ptr != NULL)
    {
        cout << ptr->nama << endl;
        ptr = ptr->berikut;
    }

    //Bebaskan memori
    while (pertama != NULL)
    {
        ptr = pertama;
        pertama = pertama->berikut;

        cout << "Akan membebaskan memori untuk "
             << ptr->nama << endl;

        delete ptr;
    }

    return 0;
}

would Read More..!

  © Blogger template 'External' by Ourblogtemplates.com 2008

Back to TOP