Advertisement
Guest User

Untitled

a guest
May 21st, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Main {
  5.  
  6. public static void otstrani(char[] golema, char[] mala){
  7.  
  8. //System.out.println("1111111111");
  9. for (int i = 0; i < golema.length; i++) {
  10. //System.out.println("22222222");
  11. int index = i;
  12. boolean ista = true;
  13. if(golema.length - i >= mala.length){
  14. for (int j = 0; j < mala.length; j++) {
  15.  
  16. char g = golema[i+j];
  17. char m = mala[j];
  18. if(g != m){
  19. ista = false;
  20. break;
  21. }
  22.  
  23. }
  24. if(ista){
  25. for (int j = 0; j < mala.length; j++) {
  26. golema[index+j] = ' ';
  27. i = index + mala.length - 1;
  28. }
  29. }
  30. }
  31.  
  32. }
  33.  
  34. // for (int i = 0; i < golema.length; i++) {
  35. // char[] tmp;
  36. // if(golema[i]!=' '){
  37. // tmp.
  38. // }
  39. // }
  40.  
  41. }
  42.  
  43. public static void main(String[] args){
  44. Scanner sc = new Scanner(System.in);
  45. String st = sc.nextLine();
  46. char niza[] = st.toCharArray();
  47.  
  48. String s = sc.nextLine();
  49.  
  50. int N = Integer.parseInt(s);
  51.  
  52. String[] podnizi = new String[N];
  53. for (int i = 0; i < N; i++) {
  54. podnizi[i] = sc.nextLine();
  55. }
  56.  
  57. //presmetaj(niza, N, podnizi);
  58.  
  59.  
  60. for (int i = 0; i < N; i++) {
  61. char[] podniza = podnizi[i].toCharArray();
  62. otstrani(niza, podniza);
  63. }
  64.  
  65. for (int i = 0; i < niza.length; i++) {
  66. if(niza[i] != ' ')
  67. System.out.print(niza[i]);
  68.  
  69. }
  70.  
  71. sc.close();
  72.  
  73.  
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement