20186-27编程素养练习

查找「sdddrtkjsfkkkasjdddj」字符串中,出现次数最多的字符和次数。

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script>
       var str ="sdddrtkjsfkkkasjdddj";
       var stu = {};


       for (var i = 0;i < str.length; i++){
            var cha = str.charAt(i);
            if (stu[cha]){
            stu[cha]++;
            }else{
            stu[cha] = 1;
            }
       }
        var max = 0;
       for (var t in stu){
            if (stu[t] >= max){
            max = stu[t];
            }
       }
       for (var e in stu){
            if (stu[e] == 6){
            console.log("出现次数最多的是:"+e+",是"+stu[e]+"次");
            }
       }
</script>
</body>
</html>



表名 team

ID Name
1 a
2 b
3 b
4 a
5 c
6 c

要求:执行一个删除语句,当 Name 列上有相同时,只保留 ID 这列上值小的
例如:删除后的结果应如下:

ID Name
1 a
2 b
5 c

DELETE FROM team WHERE id  NOT IN ( SELECT a.id FROM  (SELECT MIN(id) as id FROM team GROUP BY name) AS a );


判断 101-200 之间有多少个素数,并输出所有素数。

package S_2018_6_26;
public class Lianx {
public static int [] b = new int [100] ;
public static void main(String[] args) { 
int k = 0;
for (int i = 101; i <= 200; i++ ) {
for (int  j = 2; j < i; j++) {
if (i % j == 0 ) {
b[k] = i;
}
}
if (b[k] != 0) {
k++;
}
}
System.out.println(100-k);
}
}

猜你喜欢

转载自blog.csdn.net/ydk1983980885/article/details/80834102