Advertisement
joseleonweb

Untitled

Aug 26th, 2019
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. public class OmpleArrayParells {
  2.  
  3.   public static void main (String[] args) {
  4.  
  5.     Scanner lector = new Scanner(System.in);
  6.  
  7.     System.out.print("Quin Ês el valor de \"i\"? ");
  8.     int i = lector.nextInt();
  9.     lector.nextLine();
  10.  
  11.     int[] array = new int[i];
  12.  
  13.     array[0] = 0;
  14.     for(int j = 1; j < array.length; j++) {
  15.       array[j] = array[j - 1] + 2;
  16.     }
  17.  
  18.     for(int j = 0; j < array.length; j++) {
  19.       System.out.println(array[j]);
  20.     }
  21.   }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement