Bubble

/*
   Author :  Jemmy R. Mongi
   File :  Bubble.cpp
*/
#include <stdio.h>
#include &ltstdlib.h>

/* prototipe fungsi bubbleSort */
int bubbleSort(int *, int);

int main() {
    printf("***BUBBLE SORT***\n\n");
   
    /* minta user menginput jumlah elemen array */
    printf("Masukan jumlah elemen: ");
    int n;
    scanf("%d", &n);
   
    /* deklarasi array dengan jumlah elemen sebanyak input user */
    int A[n];
   
    /* input nilai pada elemen-elemen array */
    int input;
    for (input = 0; input < n; input++) {
        printf("A[%d]: ", input);
        scanf("%d", &A[input]);
    }
   
    system("cls");
    /* tampilkan nilai elemen-elemen array sebelum disortir */
    printf("Nilai elemen-elemen array sebelum disortir\n");
    int before;
    for (before = 0; before < n; before++)
        printf("A[%d] = %d\n", before, A[before]);
   
    /* panggil fungsi bubbleSort */
    bubbleSort(A, n);
   
    /* tampilkan nilai elemen-elemen array setelah disortir */
    printf("\nNilai elemen-elemen array setelah disortir\n");
    int after;
    for (after = 0; after < n; after++)
        printf("A[%d] = %d\n", after, A[after]);
   
    system("pause");
    return 0;
}

/* body fungsi bubbleSort */
int bubbleSort(int *A, int n) {
    int i;
    for (i = 1; i <= n-1; i++) {
        int j;
        for (j = n-1; j >= i; j--) {
            if (A[j] < A[j-1]) {
               int temp = A[j];
               A[j] = A[j-1];
               A[j-1] = temp;
            }/* if */
        }/* for j */
    }/* for i */
}/* fungsi bubbleSort() */

Binary Tree

#include<stdio.h>
#include<stdlib.h>
#include <iostream>
using namespace std;

typedef struct treeNode
{
        int data;
        struct treeNode *left;
        struct treeNode *right;

}treeNode;

treeNode* FindMin(treeNode *node)
{
        if(node==NULL)
        {
                /* There is no element in the tree */
                return NULL;
        }
        if(node->left) /* Go to the left sub tree to find the min element */
                return FindMin(node->left);
        else
                return node;
}
treeNode* FindMax(treeNode *node)
{
        if(node==NULL)
        {
                /* There is no element in the tree */
                return NULL;
        }
        if(node->right) /* Go to the left sub tree to find the min element */
                FindMax(node->right);
        else
                return node;
}

treeNode * Insert(treeNode *node,int data)
{
        if(node==NULL)
        {
                treeNode *temp;
                temp = (treeNode *)malloc(sizeof(treeNode));
                temp -> data = data;
                temp -> left = temp -> right = NULL;
                return temp;
        }

        if(data >(node->data))
        {
                node->right = Insert(node->right,data);
        }
        else if(data < (node->data))
        {
                node->left = Insert(node->left,data);
        }
        /* Else there is nothing to do as the data is already in the tree. */
        return node;
}
int main()
{
   
    system("pause");
    return 0;
    }

Virtual function

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

class Super
{
      protected :
              int a;
      public :
             virtual void Read();
};
void Super :: Read()
{
     cout<<"masukan nilai a : ";
     cin>>a;
}
class Sub : public Super
{
      protected :
              int i, j;
      public :
             void Read();
};
void Sub :: Read()
{
     cout<<"Masukan nilai i : ";
     cin>>i;
     cout<<"Masukan niali j : ";
     cin>>j;
}
int main()
{
    Super *a1 = new Super();
    a1 -> Read();
   
    Sub *a2 = new Sub();
    a2 -> Read();
   
    a1 = new Sub();
    a1 -> Read();
   
    system("pause");
    return 0;
}

Account Bank

/*
  Author : Jemmy R. Mongi
  File : Account Bank.cpp
*/

#include
#include
#include
using namespace std;
int check_balance=0;
class Akun
{
      protected :
               int deposit,withdrawl;
               char ulang;
      public :
             void Deposit();
             void Withdrawl();
             void Check_Balance();
};
void Akun :: Deposit()
{
              system("cls");
              cout<<"Please Enter Your deposit (deposit Minimal Rp.10.000,-): ";
              cin>>deposit;
              while(deposit < 10000)
              {
                   system("cls");
                   cout<<"Sorry You can't deposit under Rp.10.000,- you must deposit <
                   cout<<"Please enter again your deposit : ";
                   cin>>deposit;
              }
                   check_balance=check_balance+deposit;
                   cout<<"Thank you the deposit has been successfully...!!\n";
             
}
void Akun :: Withdrawl()
{
     int done = 0;
     while (done == 0)
     {
              cout<<"Enter your withdrawl : ";
              cin>>withdrawl;
              if(withdrawl%50000 != 0)
              {
                   system("cls");
                   cout<<"You can only make withdrawl with multiplies Rp.50.000,-"<
              }
              else if(withdrawl > check_balance)
              {
                   system("cls");
                   cout<<"Your withdrawl greater than your balance"<
              }
              else if((check_balance - withdrawl) < 100000)
              {
                   system("cls");
                   cout<<"Your balance must be Rp.100.000,- after this  trasaction"<
              }
              else if(withdrawl > 5000000)
              {
                   system("cls");
                   cout<<"Sorry maximum withdrawl is Rp.5.000.000,-\n";
              }
              else
              {
                   done = 1;
                   system("cls");
                   cout<<"Withdrawl successfully...!!\n";
                   check_balance=check_balance-withdrawl;
              }
     }
}
void Akun :: Check_Balance()
{            
              system("cls");
              cout<<"Your Balance is Rp."<
}
int main()
{
    char ulang;
    int choice;
    Akun akses;
   
    do
    {  
    system("cls");
    cout<
    cout<<"Make selection to transaction\n";
    cout<<"1. Deposit\n";
    cout<<"2. Withdrawl\n";
    cout<<"3. Check Balance\n";
    cout<<"Enter Your Choice : ";
    cin>>choice;
   
    switch(choice)
    {
         case 1 :
              akses.Deposit();
              break;
         case 2 :
              akses.Withdrawl();
              break;
         case 3 :
              akses.Check_Balance();
              break;
         default :
                 system("cls");
                 cout<<"Your choice is not available"
                     <<"\npress any key to exit..";
                     ulang=getch();
                     exit(0);
    }
    cout<<"\nDo you want to transaction again...?\n"
        <<"press y to continue or press any key to exit";
          ulang=getch();
          if(ulang!='y')
          exit(0);
    }while(ulang=='y');
   
   
    getch();
}

Tutorial Lengkap Hosting Website Gratis Dengan Gambar

Hallo Guys.. sudah sangat lama sekali sejak terakhir kali saya melakukan posting di blogger ini... kalau saya tidak salah terakhir saya ...