<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
</body>
<script>
var str = "sdddrtkjsfkkkasjdddj";
// 使用对象记录字符出现的次数,键为各个字符,值为字符出现的次数
var obj = {};
for(var i = 0; i < str.length; i++) {
//获得字符
var char = str.charAt(i);
//若对象已有该字符属性,值加1
if(obj[char]) {
obj[char]++;
} else {
//第一次出现该字符,值记为1
obj[char] = 1;
}
}
//记录出现最多次数
var max = 0;
for(var key in obj) {
if(obj[key] >= max) {
max = obj[key];
}
}
//打印
for(var key in obj) {
if(obj[key] == max) {
console.log("出现次数最多的字符:" + key);
console.log("出现次数:" + obj[key]);
}
}
</script>
</html>
要求:执行一个删除语句,当 Name 列上有相同时,只保留 ID 这列上值小的
delete from user where id not in(
select a.id from (
select min(id) as id from user group by name
) AS a
);
public static void main(String[] args) {
// 判断 101-200 之间有多少个素数,并输出所有素数。
String str= "";
int count=0;
for(int i=101;i<=200;i++) {
if(i%2==0 || i%3==0 || i%5==0) {
continue;
}else {
str += i + ",";
count++;
}
}
String str2 = str.substring(0, str.length()-1);
String[] array = str2.split(",");
System.out.println(array.length);
System.out.println(count);
}