Advertisement
Guest User

Untitled

a guest
Jun 7th, 2022
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. import java.math.BigInteger;
  2. import java.util.ArrayList;
  3. import java.util.Arrays;
  4. import java.util.Scanner;
  5.  
  6. public class mmm {
  7. public static void main(String[] args) {
  8. Scanner scanner = new Scanner(System.in);
  9.  
  10. int numbercount = Integer.parseInt(scanner.nextLine());
  11.  
  12. int position = 1;
  13. int[] numbers = new int[numbercount];
  14. int[] duplicates = new int[numbers.length];
  15. int min = 11;
  16.  
  17. for (int i = 0; i < numbercount; i++) {
  18. numbers[i] = scanner.nextInt();
  19. if (numbercount < 2) {
  20. System.out.println(numbers[i]);
  21. return;
  22. }
  23. }
  24.  
  25. for (int j = 0; j < numbercount; j++) {
  26. for (int k = position; k < duplicates.length; k++) {
  27. if (numbers[j] == numbers[k]) {
  28. duplicates[j] = numbers[k];
  29. break;
  30. }
  31. }
  32. position++;
  33. }
  34.  
  35. for (int i = 0; i < duplicates.length; i++) {
  36. if (duplicates[i] < min && duplicates[i] != 0) {
  37. min = duplicates[i];
  38. }
  39. }
  40.  
  41. if (numbercount < 1) {
  42. System.out.println();
  43. } else {
  44. System.out.println(min);
  45.  
  46. }
  47.  
  48.  
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement