首頁 > 資料庫 > mysql教程 > Given two strings S1 and S2. Delete from S2 all those charac

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

WBOY
發布: 2016-06-07 15:42:58
原創
1194 人瀏覽過

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+"!!!");

 }

}

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板