Advertisement
gwserver

Ocupar o array de forma contínua

Apr 23rd, 2021
836
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.52 KB | None | 0 0
  1.  
  2. public class Main {
  3.  
  4.     public static void main(String[] args) {
  5.  
  6.         int[] naoDivisiveisPor5 = new int[99];
  7.        
  8.         int indice = 0;
  9.  
  10.         for (int contador = 1; contador < 100; contador++) {
  11.  
  12.             if (contador % 5 == 0) {
  13.                 continue;
  14.             }
  15.             naoDivisiveisPor5[indice] = contador;
  16.             indice++;
  17.  
  18.         }
  19.        
  20.         int[] naoDivisiveisOrganizado = new int[indice];
  21.        
  22.         for (int i = 0; i < indice; i++) {
  23.             System.out.print(naoDivisiveisPor5[i] + " ");
  24.             naoDivisiveisOrganizado[i] = naoDivisiveisPor5[i];
  25.         }
  26.        
  27.  
  28.     }
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement