Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Arrays;
- import java.util.Scanner;
- public class Zada4i3 {
- public static void main(String args[]) {
- Scanner scanner = new Scanner(System.in);
- String[] words = scanner.nextLine().split(" ");
- int count = 0;
- String[] wordsDis = new String[count];
- for (int i = 0; i < words.length - 1; i++) {
- if (!words[i].equals(words[i + 1])) {
- for (int j = i+1; j < words.length; j++) {
- if (!words[i].equals(words[j])) {
- count++;
- }
- if (count == (words.length - 1) - i) {
- System.out.println(words[i]);
- count = 0;
- }
- }
- }
- }
- //last element
- int last = 0;
- for (int k = 0; k < words.length - 1; k++) {
- if (!words[words.length - 1].equals(words[k])) {
- last++;
- }
- if (last == words.length-1){
- System.out.println(words[words.length - 1]);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement