5

mail@pastecode.io avatar
unknown
java
16 days ago
2.2 kB
0
Indexable
Never
import java.util.Scanner;

public class HomeworkFive {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String string_one = sc.nextLine();
        String string_two = sc.nextLine();
        String unique_two = "";
        String final_str = "";
        char ch_x = ' ';
        char ch_y = ' ';

        for (int i = 0; i < string_two.length(); i++) {
            char ch_one = string_two.charAt(i);
            int ch_one_ascii = (int) ch_one;
            if (ch_one_ascii >= 65 && ch_one_ascii <= 90) {
                int ascii_two = ch_one_ascii + 32;
                ch_y = (char) ascii_two;
            }
            else if (ch_one_ascii >= 97 && ch_one_ascii <= 122) {
                int ascii_two = ch_one_ascii - 32;
                ch_y = (char) ascii_two;
            }
            boolean match_found = false;
            for (int j = 0; j < string_one.length(); j++) {
                if (string_one.charAt(j) == ch_one || string_one.charAt(j) == ch_y) {
                    match_found = true;
                    break;
                }
            }
            if (match_found == true) {
                unique_two += ch_one;
            }

        }
        for (int i = 0; i < unique_two.length(); i++) {
            char ch_one = unique_two.charAt(i);
            int ch_one_ascii = (int) ch_one;
            if (ch_one_ascii >= 65 && ch_one_ascii <= 90) {
                int ascii_two = ch_one_ascii + 32;
                ch_x = (char) ascii_two;
            }
            else if (ch_one_ascii >= 97 && ch_one_ascii <= 122) {
                int ascii_two = ch_one_ascii - 32;
                ch_x = (char) ascii_two;
            }

            for (int j = 0; j < string_one.length(); j++) {
                char ch_two = string_one.charAt(j);
                if (ch_one == ch_two || ch_x == ch_two) {
                    final_str += "";
                } else {
                    final_str += ch_two;
                }


            }
            string_one = final_str;
            final_str = "";

        }
        System.out.println(string_one);
    }


}
Leave a Comment