首页 > 其他 > 详细

随机数 作业

时间:2015-06-05 22:35:45      阅读:315      评论:0      收藏:0      [点我收藏+]
 1 package zuoye;
 2 
 3 import java.util.Random;
 4 
 5 public class Test1 {
 6     public static void main(String[] args) {
 7         Random rand = new Random();
 8         int arr[] = new int[10];
 9         for (int i = 0; i < arr.length; i++) {
10             arr[i] = rand.nextInt(100);
11             System.out.print(arr[i] + "\t");
12         }
13         System.out.println();
14         RandomNum rn = new RandomNum(arr);
15     }
16 }
17 
18 class RandomNum {
19     int arr[];
20 
21     public RandomNum(int arr[]) {
22         this.arr = arr;
23     }
24 
25     public double getMaxNum(int arr[]) {
26         int max = arr[0];
27         for (int i = 0; i < arr.length; i++) {
28             if (arr[i] > max)
29                 max = arr[i];
30         }
31         System.out.println("The max num of the array is " + max);
32         return max;
33     }
34 
35 }

 

随机数 作业

原文:http://www.cnblogs.com/xs-yqz/p/4555662.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!