import javax.swing.JOptionPane;
public class inputarray {
public static void main(String[] args) {
String ukuran,ai;
int xmax=0;
ukuran=JOptionPane.showInputDialog(null,"jumlah data ?");
int n =Integer.parseInt(ukuran);
int a[]=new int[n+1];
int i=1;
for(i=1;i<=n;i++){
ai=JOptionPane.showInputDialog(null,"data ke-"+i);
a[i]=Integer.parseInt(ai);
}
System.out.println("banyak data : "+n);
System.out.print(a[1]+" ");
int k;
xmax=a[1];
for(k=2;k<=n;k++){
if(xmax<=a[k]){
xmax=a[k];
}
System.out.print(a[k]+" ");
}
System.out.println("\n nilai maximal : "+xmax);
}
}
public class inputarray {
public static void main(String[] args) {
String ukuran,ai;
int xmax=0;
ukuran=JOptionPane.showInputDialog(null,"jumlah data ?");
int n =Integer.parseInt(ukuran);
int a[]=new int[n+1];
int i=1;
for(i=1;i<=n;i++){
ai=JOptionPane.showInputDialog(null,"data ke-"+i);
a[i]=Integer.parseInt(ai);
}
System.out.println("banyak data : "+n);
System.out.print(a[1]+" ");
int k;
xmax=a[1];
for(k=2;k<=n;k++){
if(xmax<=a[k]){
xmax=a[k];
}
System.out.print(a[k]+" ");
}
System.out.println("\n nilai maximal : "+xmax);
}
}
0 komentar:
Posting Komentar