// Program 9: Remove a Word at a Given Position import java.util.*; class DeleteWord { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.nextLine().trim(); String target = sc.next(); int position = sc.nextInt(); String[] words = new String[s.length() + 1]; int size = 0; String word = ""; for (int i = 0; i < s.length(); i++) { char ch = s.charAt(i); if (ch == '.' || ch == '?' || ch == '!') { break; } if (ch == ' ') { if (word.length() > 0) { words[size++] = word; word = ""; } } else { word += ch; } } if (word.length() > 0) { words[size++] = word; } if (position < 1 || position > size || !words[position - 1].equals(target)) { System.out.println("Word not found at position"); return; } for (int i = 0; i < size; i++) { if (i != position - 1) { System.out.print(words[i] + " "); } } } }