Given two strings S1 and S2. Delete from S2 all those charac

WBOY
Lepaskan: 2016-06-07 15:42:58
asal
1176 orang telah melayarinya

Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted. public class StringManipulation { public static void main(String args[]) { String s

 Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.

 

 

 

 

 

public class StringManipulation {

 public static void main(String args[]) {

  String s1 = "ba";
  String s2 = "cbaaaabbcaaaa";
  
  
  for (int i = 0; i    for (int j = 0; j>=0 && s2.length()>0 &&j    
    while(s1.charAt(i) ==s2.charAt(j)){//处理连续状况
     s2 = s2.substring(0, j) + s2.substring(j + 1);
       j--;
       System.out.println(s2+s2.length()+"  "+j);
       if(j        if(s2.equals(""))break;
    }
   }
  }

  System.out.println(s2+"!!!");

 }

}

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan