Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class Test
- {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int[] arr = new int[9];
- int i = 0;
- int c = 1;
- boolean b = false;
- System.out.println("enter nums; ");
- while (i<9) {
- arr[i] = sc.nextInt();
- i++;
- }
- i = 0;
- while (i<9) {
- while (c<9) {
- if (arr[i] == 0 && arr[c] == 0) {
- break;
- }
- else if (arr[i] == arr[c]) {
- arr[c] = 0;
- b = true;
- }
- c++;
- }
- if (b) {
- arr[i] = 0;
- }
- b = false;
- i++;
- c = i + 1;
- }
- System.out.println(Arrays.toString(arr));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement