Day/009

JavaScript 编程题

null 和 undefined 的区别?

null: Null类型,代表“空值”,代表一个空对象指针,使用typeof运算得到 “object”,所以你可以认为它是一个特殊的对象值。
undefined: Undefined类型,当一个声明了一个变量未初始化时,得到的就是undefined。
null表示"没有对象",即该处不应该有值。典型用法是:
(1) 作为函数的参数,表示该函数的参数不是对象。
(2) 作为对象原型链的终点。
undefined表示"缺少值",就是此处应该有一个值,但是还没有定义。典型用法是:
(1)变量被声明了,但没有赋值时,就等于undefined。
(2) 调用函数时,应该提供的参数没有提供,该参数等于undefined。
(3)对象没有赋值的属性,该属性的值为undefined。
(4)函数没有返回值时,默认返回undefined。

MySQL 编程题

在这里插入图片描述
查询出只选修了一门课程的全部学生的学号和姓名。

SELECT sno,username FROM students GROUP BY sno,username HAVING count(course) = 1;

Java 编程题

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

public class Demo {
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);
}
}
}
}
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/czy2457287516/article/details/83277558
009
今日推荐