zoukankan      html  css  js  c++  java
  • java作业——Day009

    JavaScript 编程题

    null 和 undefined 的区别?

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


    MySQL 编程题

    表名 students

    idsnousernamecoursescore
    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 students
    GROUP BY sno,username
    HAVING count(course) = 1;

    Java 编程题

    打印出所有的「水仙花数」,所谓「水仙花数」是指一个三位数,其各位数字立方和等于该数本身。例如: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);
                }
            }
        }
    }

    执行结果:

  • 相关阅读:
    DataGrid
    取整、取小数点位数
    如何跨浏览器使用连续字符的换行
    如何给 legend 标签设定宽度
    25个简洁优美的网站设计
    重新发现HTML表格
    用户研究角度看设计(2):用户为何视若无睹
    lineheight 属性的继承问题
    jQuery技巧总结
    web2.0网站配色方案
  • 原文地址:https://www.cnblogs.com/ntdx-zhoulei/p/11308369.html
Copyright © 2011-2022 走看看