2017.12.17

来源:互联网 发布:js上拉查看图文详情 编辑:程序博客网 时间:2024/06/07 12:14

null 和 undefined 的区别?

undefined 类型只有一个值,即 undefined。当声明的变量还未被初始化时,变量的默认值为 undefined。
null 类型也只有一个值,即 null。null 用来表示尚未存在的对象,常用来表示函数企图返回一个不存在的对象。

表名 students

id sno username course score
1 1 张三 语文 50
2 1 张三 数学 80
3 1 张三 英语 90
4 2 李四 语文 70
5 2 李四 数学 80
6 2 李四 英语 80
7 3 王五 语文 50
8 3 王五 英语 70
9 4 赵六 数学 90
查询出只选修了一门课程的全部学生的学号和姓名。

SELECT sno,username,count(course) FROM studentsGROUP BY sno,usernameHAVING count(course) = 1;

打印出所有的「水仙花数」,所谓「水仙花数」是指一个三位数,其各位数字立方和等于该数本身。例如:153 是一个「水仙花数」,因为 153=1的三次方+5 的三次方+3 的三次方。

package ntqingniao.java;public class Test {    public static void main(String[] args) {        for (int num = 100; num <= 1000; num ++) {            //個位數            int a = num %10;            //十位數            int b = num/10%10;            // 百位数            int c = num / 100 % 10;            if (Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3) == num) {                System.out.println(num);            }        }    }

}

原创粉丝点击