Contoh Program Stack Dengan Array Di Java

Contoh Program Stack Dengan Array Di Java

April 25, 2014 Add Comment
contoh program stack tapi pake array.... bisa di liat dan dipelajari...






import java.util.Scanner;
import java.util.Stack;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Zen
 */
public class stackcoba {
    static Scanner zen = new Scanner(System.in);
    static int max;
    static Object arrstack[];
    static String pushh;
    static int i;
    static int j;
    static int help[];
    static String topp;
    static int top=-1;
   
   
   
    static void push(){
     Stack baru = new Stack();
     arrstack=new String [max];
        for ( i = 0; i < max; i++) {
           System.out.print("Push -> ");  
           arrstack[i] = zen.next();
            show();
        } 
    }
   
    public int find(){
        return (top+1);
    }
   
    static void show(){
        for (int k = 0; k < max; k++) {
            System.out.print("["+arrstack[k]+"],");  
        }
        System.out.println();
    }
   
    static void show2(){
        for (int k = max-1; k >= 0; k--) {
           System.out.print("["+arrstack[k]+"],"); 
        }
    }
   
    static void pop (){
       // arrstack=new String[max];
        System.out.println("To stop input ''stop''");
        for ( j = max-1; j >= 0; j--) {
            System.out.print("Pop -> ");
          topp=zen.next();
          
          if (topp.contains((CharSequence) arrstack[j])) {
             arrstack[j]=null;
            
         show();
      
          }else{
              show();
              break; 
          }
        }
    }
   
    public static void main(String[] args) {
        System.out.print("Masukkan Nilai Maksimum Stack : ");
        max=zen.nextInt();
        stackcoba z = new stackcoba();
                   z.push();
                   z.pop();
    
    }
}
Contoh Program Stack Pada Pemrograman Java

Contoh Program Stack Pada Pemrograman Java

April 25, 2014 Add Comment
ini tugas ke 3 Struktur data, Stack inputan bisa di liat..

 


/
import java.util.Scanner;
import java.util.Stack;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Zen
 */
public class stackcoba2 {
    static Stack zen = new Stack();
    static Scanner in = new Scanner(System.in);
    static String a;
    static String arr;
    static int max_st;
    static int i=0;
    static int top =-1;
    static void pushh(Stack zen, String a){
        zen.push((a).toString());
        System.out.println("Stack: " + zen);
    }
   public int find(){
        return (int) (top=top+1);
    }
   
   
    static void popp(Stack zen, String a ){
        a = (String) zen.pop();
        System.out.println("stack: " + zen);
    }
   
    public static void main(String[] args) {
        System.out.print("Masukkan Max_Stack : "); 
    max_st=in.nextInt();
        for (int i = 0; i < max_st; i++) {
            System.out.print("PUSH -> ");
            a=in.next();
            pushh(zen, a);   
        }
        System.out.println("POP = y / anykeys=stop");
      while(!a.equals("n")){
            System.out.print("POP ->  ");
               a=in.next();
               if (a.equals("y") && !zen.isEmpty()) {
                  popp(zen, a);
                 
            }else{
                   System.out.println("apa stack kosong?  "+zen.isEmpty());
                   break;
               }
         
            System.out.println("apa stack kosong?  "+zen.isEmpty());
             if (zen.isEmpty()) {
                       System.out.println("stop");
                       break;
                 }
        }
    }
}
The First Trophy

The First Trophy

April 25, 2014 Add Comment


                   it starts from here //loving english language was a very awesome hobby, penghargaan pertama yang aku peroleh .

                 waktu itu aku ga tau kapan tepat waktunya..... guru smpku tiba tiba nyuruh aku ikut story telling, wah kesempatan banget!!! tapi waktu itu everything was not as good as now for this international language,,, tapi aku yakin dengan semangat aka pasti bisa..

            saat yang dinanti tiba saat yg lain punya alat peraga buat tell their story aq cuma hanya punya mimik muka dan expresi.... tapi untung waktu itu aq bisa all out !!! expresiku waktu jadi ibu maling kundang buat yang lain kaget dan terpana hasek haseeekk..

           trus act terjatuh ,,,, buat yg lain ngakak tapi keep watching
pada ahirnya aq anggap penampilanku adalah yg terbaik dari yg ada...


       saat pengumuman kita keluar dulu ..... aq sempet unconfident.... tapi pas masuk ke kelas tiba tiba namaku di panggil dan juara harapan 3, tapi anehnya yang juara juara diatasku malah mereka yg  less in speaking ... and it was nothing at all.

      there must be something they hide, cheating in game  always happens .. even in competitions, it must be happened in every competitions which is held in this town.