Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
750 B
2
Indexable
Never
package ex_arr;

import java.util.Random;
import java.util.Scanner;

public class ex_arr {
	
	static void FillArr (int [] arr) {
		 Random r = new Random();	 
	        for(int i=0;i<arr.length;i++)
	        {
	            arr[i] = r.nextInt(-99,99);	            
	            }
	}
	static void PrintArr(int [] arr) {
		for(int i=0; i < arr.length; i++ ) {
			System.out.print(arr[i] + " ");
		}
		 
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.print("Введите количество элементов массива: ");
		int count = (int) sc.nextDouble();	
		
	      int[] arr;
	      arr = new int[count]; 
	      FillArr (arr);  
	      PrintArr (arr);
	}
}