null 和 undefined 的區別?javascript
undefined 類型只有一個值,即 undefined。當聲明的變量還未被初始化時,變量的默認值爲 undefined。
null 類型也只有一個值,即 null。null 用來表示還沒有存在的對象,經常使用來表示函數企圖返回一個不存在的對象。java
表名 studentsmysql
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 |
查詢出只選修了一門課程的所有學生的學號和姓名。sql
SELECT sno,username,count(course) FROM students GROUP BY sno,username HAVING count(course) = 1;
打印出全部的「水仙花數」,所謂「水仙花數」是指一個三位數,其各位數字立方和等於該數自己。例如:153 是一個「水仙花數」,由於 153=1的三次方+5 的三次方+3 的三次方。編程
package test; /** * @author CUI * */ 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); } } } }
執行結果:函數