Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package MockExam4;
- import java.util.Scanner;
- public class Exercise3 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- String word = scan.nextLine();
- int n = Integer.parseInt(scan.nextLine());
- StringBuilder result = new StringBuilder(word);
- for (int i = 0; i < n; i++) {
- String input = scan.nextLine().toLowerCase();
- String sequence = "";
- int index = 0;
- for (int j = 0; j < result.length(); j++) {
- if (input.charAt(index) == result.charAt(j)){
- sequence += String.valueOf(input.charAt(index++));
- }
- if (index > input.length() - 1){
- break;
- }
- }
- if (sequence.equals(input)){
- for (int j = 0; j < sequence.length(); j++) {
- for (int k = 0; k < result.length(); k++) {
- if (sequence.charAt(j) == result.charAt(k)){
- result.deleteCharAt(k);
- break;
- }
- }
- }
- System.out.println(result);
- }else {
- System.out.println("No such title found!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement