Go to diff to previous submission
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class Bugs { while (true) { if (vstupRadka == null) { break; } Scanner sc = new Scanner(vstupRadka); int n = sc.nextInt(); for (int i = 0; i < n; i++) { if (!radka.contains(slovo)) { } else { while (true) { radka = radka.replace(slovo, ""); if (!radka.contains(slovo)) { break; } } } } } } }
--- c4.s881.cteam118.bugs.java.0.Bugs.java +++ c4.s909.cteam118.bugs.java.0.Bugs.java @@ -28,13 +28,15 @@ System.out.println(radka); } else { - String stary = radka; + while (true) { - String novy = stary.replace(slovo, ""); - if (novy.equals(stary)) { - System.out.println(novy); + radka = radka.replace(slovo, ""); + if (!radka.contains(slovo)) { + System.out.println(radka); break; } - stary = novy; + } + + } }