fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[] vetor = {4,6,2,2,8,2,0};
  13.  
  14. for (int i = 0; i < vetor.length; i++) {
  15. boolean repetiu = false;
  16.  
  17. for (int j = 0; j < vetor.length; j++) {
  18. if (vetor[i] == vetor[j] && i != j) { // verificando repeticao
  19. repetiu = true; // numero repetiu
  20. break; // se repetiu ao menos uma vez, entao nao eh necessario
  21. // percorrer todo o vetor
  22. }
  23. }
  24.  
  25. if (!repetiu) System.out.println(" " + vetor[i] + " ");
  26. }
  27. }
  28. }
Success #stdin #stdout 0.12s 50188KB
stdin
Standard input is empty
stdout
 4 
 6 
 8 
 0