Day009

1、null 和 undefined 的区别?

        undefined 类型只有一个值,即 undefined。当声明的变量还未被初始化时,变量的默认值为 undefined。

        null 类型也只有一个值,即 null。null 用来表示尚未存在的对象,常用来表示函数企图返回一个不存在的对象。

2、

Day009

    查询出只选修了一门课程的全部学生的学号和姓名。

  1. SELECT sno AS '学号',username AS '姓名' FROM student   
  2. GROUP BY sno,username  
  3. HAVING count(course) = 1;  

输出结果:

Day009

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

[java] view plain copy
  1. public class Day009 {  
  2.     public static void main(String[] args) {  
  3.         /* 打印出所有的「水仙花数」,所谓「水仙花数」是指一个三位数,其各位数字立方和等于该数本身。 
  4.         例如:153 是一个「水仙花数」,因为 153=1的三次方+5 的三次方+3 的三次方。 */  
  5.         for (int num = 100; num < 1000; num++) {  
  6.             // 个位数  
  7.             int a = num % 10;  
  8.             // 十位数  
  9.             int b = num / 10 % 10;  
  10.             // 百位数  
  11.             int c = num / 100 % 10;  
  12.   
  13.             if (Math.pow(a, 3) + Math.pow(b, 3) + Math.pow(c, 3) == num) {  
  14.                 System.out.println(num);  
  15.             }  
  16.         }  
  17.     }