網頁

2014年5月20日 星期二

利用Random產生int陣列並找出最大的值

利用Random產生int陣列並找出最大的值

33 則留言:

  1. B10233082 唐偉強2014年5月20日 上午9:43

    package dcdcdcdcd;
    import java.util.*;
    public class fvfvfvfvfv {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;i<a.length;i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=0;i<a.length;i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  2. package hello0520;
    import java.util.*;
    public class ex3 {
    public static void main(String[] args) {
    Random rnd =new Random();
    int [] a =new int[10];
    for(int i=0;i<a.length;i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=1;i<a.length;i++)
    if(a[i]>max)max=a[i];
    System.out.println(max);
    }
    }

    回覆刪除
  3. package hello520;
    import java.util.*;
    public class ex3 {
    public static void main(String[] args) {
    Random rnd=new Random();
    int [ ] a=new int[10];
    for (int i=0;i<10;i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+" \t ");
    }
    System.out.println();
    int max =a[0];
    for (int i=1;i<a.length;i++)
    if (a[ i ]>max) max=a[ i ];
    System.out.println(max);
    }
    }

    回覆刪除
  4. B10233069連于傑2014年5月20日 上午9:48

    import java.util.Random;


    public class Hello522 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int[10];
    for (int i=0;i<a.length ;i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");

    }
    System.out.println();
    int max=a[0];
    for(int i=1;i<a.length ;i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  5. package hello;
    import java.util.*;
    public class ex3 {

    public static void main(String[] args) {
    Random rnd = new Random();
    int [] a= new int [10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }
    }

    回覆刪除
  6. package hello;
    import java.util.*;
    public class ex3 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[]a=new int[10];
    for(int i=0;imax)max=a[i];
    System.out.print(max);
    }

    }

    回覆刪除
  7. package gang520;
    import java.util.*;
    public class ex3 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int [] a= new int [10];
    for(int i=0; i<a.length;i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");

    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  8. b10233072黃君寰2014年5月20日 上午9:55

    package aa;

    import java.util.Random;

    public class bb {

    public static void main(String[] args) {
    Random rnd = new Random();
    int [][] a=new int[5][8];
    for(int i=0; i<5;i++){
    for(int j=0 ;j<8; j++){
    a[i][j]=rnd.nextInt(100);
    System.out.print(a[i][j]+"\t");
    }
    System.out.println();
    }


    }

    }

    回覆刪除
  9. package tttt;
    import java.util.*;
    public class ggggg {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for (int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");

    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  10. package asd123;
    import java.util.*;
    public class zxc123 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  11. b10233072黃君寰2014年5月20日 上午9:56

    package aa;

    import java.util.Random;

    public class cc {

    public static void main(String[] args) {
    Random rnd=new Random();
    int [] a= new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  12. B10233062 黃聖評2014年5月20日 上午10:02

    package she1;
    import java.util.*;
    public class she12 {

    public static void main(String[] args) {
    Random rnd = new Random();
    int[] a=new int[10];
    for(int i=0; imax)max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  13. B10233108 林宣瑋2014年5月20日 上午10:03

    package laolin;

    import java.util.Random;

    public class laolin0520 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int [] a= new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length;i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  14. package hello;
    import java.util.*;
    public class ex3 {

    public static void main(String[] args) {
    Random rnd = new Random();
    int[] a= new int[10];
    for(int i=0; imax) max=a[i];
    System.out.println();
    }

    }

    回覆刪除
  15. package kkk;
    import java.util.*;
    public class kk520 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int [] a= new int[10];
    for (int i = 0; i < a.length; i++) {
    a[i] = rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for (int i = 1; i < a.length; i++)
    if (a[i] > max) max = a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  16. package hello0520;

    import java.util.Random;

    public class ex3 {
    public static void main(String[] args) {
    Random rnd=new Random();
    int [] a=new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  17. B10233081 藍立凱2014年5月20日 上午10:09

    package hello520;

    import java.util.*;

    public class ex3 {

    public static void main(String[] args) {
    Random rnd = new Random();
    int [] a= new int [10];
    for(int i=0;i<a.length;i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int small = a[0];
    for(int i=1;i<a.length;i++)
    if(a[i]<small)small=a[i];
    System.out.println(small);

    }

    }

    回覆刪除
  18. package B10233095;
    import java.util.*;
    public class BBBB000 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  19. package hihihi;

    import java.util.Random;

    public class hi0520 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int [] a= new int[10];
    for(int i=0; imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  20. B10233097 邱宥甄2014年5月20日 上午10:12

    package asd;

    import java.util.Random;

    public class max {

    public static void main(String[] args) {
    Random rnd=new Random();
    int [] a= new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  21. B10233077 古承翰2014年5月20日 上午10:14


    package TYTYTYT;
    import java.util.*;
    public class FKIO {
    Wfvfv
    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  22. B10233077 古承翰2014年5月20日 上午10:14


    package TYTYTYT;
    import java.util.*;
    public class FKIO {
    Wfvfv
    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  23. B10233077 古承翰2014年5月20日 上午10:14


    package TYTYTYT;
    import java.util.*;
    public class FKIO {
    Wfvfv
    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  24. B10233084 陳億如2014年5月20日 上午10:20

    package hello0520;
    import java.util.*;
    public class ex3 {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int[10];
    for (int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max=a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }
    }

    回覆刪除
  25. public static void main(String[] args) {
    Random rnd = new Random();
    int [] a = new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(100);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max = a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  26. public static void main(String[] args) {
    Random rnd = new Random();
    int [] a = new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(100);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max = a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  27. public static void main(String[] args) {
    Random rnd = new Random();
    int [] a = new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(100);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max = a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  28. public static void main(String[] args) {
    Random rnd = new Random();
    int [] a = new int[10];
    for(int i=0; i<a.length; i++){
    a[i]=rnd.nextInt(100);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max = a[0];
    for(int i=1; i<a.length; i++)
    if(a[i]>max) max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  29. package ddd;

    import java.util.Random;

    public class bb {

    public static void main(String[] args) {
    Random rnd = new Random();
    int [][] a=new int[5][8];
    for(int i=0; i<5;i++){
    for(int j=0 ;j<8; j++){
    a[i][j]=rnd.nextInt(100);
    System.out.print(a[i][j]+"\t");
    }
    System.out.println();
    }


    }

    }

    回覆刪除
  30. package aa;

    import java.util.Random;

    public class bb {

    public static void main(String[] args) {
    Random rnd = new Random();
    int [][] a=new int[5][8];
    for(int i=0; i&lt;5;i++){
    for(int j=0 ;j&lt;8; j++){
    a[i][j]=rnd.nextInt(100);
    System.out.print(a[i][j]+&quot;\t&quot;);
    }
    System.out.println();
    }


    }

    }

    回覆刪除
  31. B10233063 張宜禎2014年5月20日 上午10:35

    package hello0520;

    import java.util.Random;

    public class ex3 {

    public static void main(String[] args) {
    Random rnd = new Random();
    int [] a= new int [10];
    for(int i=0;i<a.length;i++){
    a[i]=rnd.nextInt(1001);
    System.out.print(a[i]+"\t");
    }
    System.out.println();
    int max = a[0];
    for(int i=1;i<a.length;i++)
    if(a[i]>max)max=a[i];
    System.out.println(max);
    }

    }

    回覆刪除
  32. B10233073 楊博宇2014年6月10日 上午10:41

    package roger545661;
    import java.util.*;
    public class rggrgrg {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除
  33. B10233074 許逸憲2014年6月10日 上午10:47

    package b12123123;
    import java.util.*;
    public class fbbbbbvfv {

    public static void main(String[] args) {
    Random rnd=new Random();
    int[] a=new int [10];
    for(int i=0;imax) max=a[i];
    System.out.println(max);

    }

    }

    回覆刪除

HTML 編輯器