Wednesday, November 9, 2011

the secret of shalat



Shalat is one of responsibility that the Muslim must done five times in each day
so many people in the world who said that they are Muslim but do not do it properly, and maybe they don't know what's the essence of shalat.
1. with shalat we can try to be discipline in our life, because the time of shalat was already decided by our god
2. Salat can make us helathy :
- When we stand in our shalat, it'll help us straighten our backbone
- In Rukuk (bow down position in shalat), it'll help us pull the backbone, so it can make our nerve loosen, and relaxing it.
- kneeling (Sujud) : this position will make all of our muscle contracting, that also make it stronger, and healthier, and also make our blood blood vessel and our lymph got massage. this position also help our heart, and prevent our blood vessel from shrinking
and there are a lot of thing then that thing that I write above..
that's just some of it..
so lets shalat

package koderekursi;
import java.util.Scanner;


public class rekursi{
public static long faktorial (int n){
if ((n!=1)&& (n!=0))
return (n*faktorial(n-1));
else
{
return (1);
}
}

public static void main(String[] args) {
int n;
Scanner input=new Scanner (System.in);
System.out.print("masukkan bilangannya :");
n=input.nextInt();
System.out.print("hasil faktorial :"+faktorial (n)+"\n");
}

}


in the code below, we'll make a factorial method in java using "rekursi" i don't how to say it in english hehehe :P
we can see on the class below, that it used method to call the value of n,
method if.... return means that the value of n, will be multiplied as long as the value of n not 0 or 1, when it reach 1, then the loop will stop.

Monday, November 7, 2011

Program Quick Sort


public class Main {
public static void main(String a[]){
    int i;
    int array[] = {7,1,5,4,13,11};
    quick_srt(array,0,array.length-1);
    System.out.print("nilai yang telah disusun");
    for(i = 0; i <array.length; i++)
      System.out.print(array[i]+"  ")
  }
  public static void quick_srt(int array[],int bag_kiri, int bag_kanan){
    int i = bag_kiri;
    int j = bag_kanan;
    if (i >= j) {
      return;
    }
    int pivot = array[(i + j) / 2];
    while (i < j)
    {
      while (i<j && array[i] < pivot) {
        i++;
      }
      while (i<j && array[j] > pivot) {
        j--;
      }
      if (i < j) {
        int T = array[i];
        array[i] = array[j];
        array[j] = T;
      }
    }
    if (i < j) {
      int T = j;
      j = i;
      i = T;
    }
    quick_srt(array, bag_kiri, i);
    quick_srt(array, i == bag_kiri ? i+1 : i, bag_kanan);
  }
}