• 编程素养Day009


    Q1:JavaScript 编程题

    null 和 undefined 的区别?

    【分析】

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

    Q2:MySQL 编程题

    表名 students

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

    【分析】先将学生学号、姓名进行分组,计算他的选课数量,如果选修的是一门课程,则选出来。

    SELECT sno,username,count(course)    不能少!!!

    代码如下:

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

    Q3:Java 编程题

    打印出所有的「水仙花数」,所谓「水仙花数」是指一个三位数,其各位数字立方和等于该数本身。

    例如:153 是一个「水仙花数」,因为 153=1的三次方+5 的三次方+3 的三次方。

    package test;
    
    public class test009 {
    
        public static void main(String[] args) {
            // TODO Auto-generated method stub
            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);
                }
            }
        }
    
    }

    运行结果:

  • 相关阅读:
    python学习-3 字典
    python学习-3
    python学习-3
    python学习日记-2
    python学习日记
    FTP文件传输
    unity实现截屏功能
    使用C++来写数据库
    background使用
    一张图说明DIV盒子距离
  • 原文地址:https://www.cnblogs.com/CYChenYuan/p/11320483.html
Copyright © 2020-2023  润新知