Source code for submission s1059

SoftwareBugs.java

  1.  
  2. import java.io.BufferedReader;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5. import java.util.Scanner;
  6.  
  7. /**
  8.  *
  9.  * @author cteam070
  10.  */
  11. public class SoftwareBugs {
  12.  
  13. /**
  14.   * @param args the command line arguments
  15.   */
  16. public static void main(String[] args) throws IOException {
  17.  
  18. Scanner sc = new Scanner(System.in);
  19. StringBuilder line;
  20. while (sc.hasNextInt()) {
  21. int t = sc.nextInt();
  22. String bug = sc.next();
  23. int len = bug.length();
  24.  
  25.  
  26. for (int i = 0; i < t; i++) {
  27. int n = 0;
  28. line = new StringBuilder(br.readLine());
  29. while (true) {
  30. n = line.indexOf(bug, n);
  31. if (n == -1) {
  32. break;
  33. }
  34.  
  35. line = line.delete(n, n + len);
  36. n = n + 1 > len ? n + 1 - len : 0;
  37. }
  38. System.out.println(line);
  39. }
  40.  
  41. }
  42. }
  43. }
  44.