DESKTOP-86ONKLH_20200829-刘天阳
1、问题
-
计算字符串的所有碎片的平均长度
public static void main(String[] args) { double b=1;
String s = "aaabbcccdddamo";
char[] t = s.toCharArray();
char temp = t[0];
for(int x=0;x<s.length();x++) {
if(t[x]!=temp) {
temp = t[x];
b +=1;
}
}
System.out.println(s.length()/b);
}
2、吐槽
考的不好,选择题做的不够细;概念记得不全,答不到点上。
点赞