JAVA easy random for loop
- package firstjava;
- import java.util.Scanner;
- public class Forloop {
- public static void main(String[] args) {
- java.util.Scanner input = new java.util.Scanner(System.in);
- int i;
- int[] mylist = new int[10];
- for ( i=0 ; i<mylist.length ; i++ ){
- mylist[i] = (int)(Math.random()*100);
- System.out.println( mylist[i] + " " );
- }
- }
- }
mistake you may make:
on line 10. (int) Math.random()*100
先做前面double變成0
留言
張貼留言