Source code for submission s652

Main.java

  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. /**
  6. * @param args
  7. * @throws FileNotFoundException
  8. */
  9.  
  10.  
  11. // printfBUG("Hello, world!/n");
  12. public static void main(String[] args) {
  13. Scanner sc = new Scanner(System.in);
  14.  
  15. while(sc.hasNextLine()) {
  16.  
  17. int pocetRadku = sc.nextInt();
  18. String podretezec = sc.nextLine().trim();
  19. String vysledek = "";
  20. for (int i = 0; i < pocetRadku; i++) {
  21. String radek = sc.nextLine();
  22.  
  23. int a = 0;
  24.  
  25. while(true) {
  26. a = radek.lastIndexOf(podretezec);
  27. if(a < 0) {
  28. System.out.println(radek);
  29. break;
  30. }
  31.  
  32. vysledek = radek.substring(0,a);
  33. vysledek += radek.substring(a+podretezec.length(),radek.length());
  34. radek = vysledek;
  35. }
  36.  
  37.  
  38. }
  39. }
  40.  
  41. }
  42.  
  43. }
  44.