Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void otstrani(char[] golema, char[] mala){
- //System.out.println("1111111111");
- for (int i = 0; i < golema.length; i++) {
- //System.out.println("22222222");
- int index = i;
- boolean ista = true;
- if(golema.length - i >= mala.length){
- for (int j = 0; j < mala.length; j++) {
- char g = golema[i+j];
- char m = mala[j];
- if(g != m){
- ista = false;
- break;
- }
- }
- if(ista){
- for (int j = 0; j < mala.length; j++) {
- golema[index+j] = ' ';
- i = index + mala.length - 1;
- }
- }
- }
- }
- // for (int i = 0; i < golema.length; i++) {
- // char[] tmp;
- // if(golema[i]!=' '){
- // tmp.
- // }
- // }
- }
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- String st = sc.nextLine();
- char niza[] = st.toCharArray();
- String s = sc.nextLine();
- int N = Integer.parseInt(s);
- String[] podnizi = new String[N];
- for (int i = 0; i < N; i++) {
- podnizi[i] = sc.nextLine();
- }
- //presmetaj(niza, N, podnizi);
- for (int i = 0; i < N; i++) {
- char[] podniza = podnizi[i].toCharArray();
- otstrani(niza, podniza);
- }
- for (int i = 0; i < niza.length; i++) {
- if(niza[i] != ' ')
- System.out.print(niza[i]);
- }
- sc.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement