Rabu, 06 Juni 2012

Mentranspose Array dalam Java Menggunakan Inputan User :


import javax.swing.JOptionPane;
/**
 *
 * @author ika
 */
public class Array {
    public static void main (String []args){
        int bmt1=Integer.parseInt(JOptionPane.showInputDialog("Masukkak baris"));
        int kmt1=Integer.parseInt(JOptionPane.showInputDialog("Masukkak Kolom"));
        int matrik1[][]=new int [bmt1][kmt1];
          for(int i=0; i
            for (int j=0 ;j
       matrik1[i][j]=Integer.parseInt(JOptionPane.showInputDialog("[matrik1]\n Baris ke-"+i+" Kolom ke-"+j));
             }
            System.out.println("Matrik Sebelum Transpose");
             for(int i=0; i
                for (int j=0 ;j
                   System.out.print(" "+matrik1[i][j]);
                           System.out.println();
             }
             System.out.println("Matrik Sesudah Transpose");
             for(int i=0; i
                for (int j=0 ;j
                   System.out.print(" "+matrik1[j][i]);
                           System.out.println();
             }
    }
}

Soure Code Selection Sort Menggunakan Inputan user (javac.swing) :


package Pertemuan5;
import javax.swing.JOptionPane;
/**
 *
 * @author ika
 */
public class Selection {
    public static void main(String[] args){
        int x =Integer.parseInt(JOptionPane.showInputDialog("Masukkan Data"));
          int i, temp, j;
        int[]data=new int[x];
        for(int index=0;index
       data[index]=Integer.parseInt(JOptionPane.showInputDialog("Masukkan angka ke -"+(index+1)));
        System.out.println("Sebelum diurutkan :");
            for(i=0;i
            System.out.print(data[i]+"\t");
            System.out.println("\n");
                for(i=0;i
                    for(j=i+1;j
                        if(data[i]>data[j]){
                            temp = data[i];
                            data[i] = data[j];
                            data[j] = temp;
                        }
                    }
                for(int k=0;k
                    System.out.print(data[k]+"\t");
                        System.out.println();
                    }
                System.out.println("Setelah diurutkan :");
                    for(i=0;i
                    System.out.print(data[i]+"\t");
                }
         }

TOP ENTRY