话不多说,直接上代码........... public static void main(String[] args) { String str="I'm go to swimming"; Set<String> set=new HashSet<>(); for (int i = 0; i < str.length(); i++) { String s = str.substring(i, i+1); set.add(s); } Iterator<
有一个字符串 “aaddfdfdercfghfyttefsfsfewretr123trefg5624sdfcgvfdgte6435234532”,现在需要取出里面出现次数最多的字符 第一种方法-装饰器 class get_max_count_string: def __init__(self,func): self.func=func self.count={} def __call__(self, args): for s in args:
三种java 去掉字符串中的重复字符函数 public static void main(string[] args) { system.out.println(removerepeatedchar("ddddccffgd")); } public static string removerepeatedchar(string s) { if (s == null) return s; stringbuilder sb = new stringbuilder(); , len = s.
第二题:计算字符串中所有数字的和1.字符串中只有小写字母和数字2.数字可能连续,也可能不连续3.连续数字要当做一个数处s='1234adg3g11's1 = "" for i in s : if i.isdigit(): s1=s1+i else: s1=s1+" " lt = s1.split(" ") m= 0 for a in lt : if a.isdigit(): m=m+int(a) print(m) *解决思想:把字符串中得数字调出