#JavaScript 编程题
页面上输入一个年份(需验证),判断是否是闰年(能被 4 整除,却不能被 100 整除的年份;能被 400 整除的是闰年),并且在页面上显示相应提示信息。
<!doctype html>
#MySQL 问答题
如何通过命令提示符登入 MySQL?如何列出所有数据库?如何切换到某个数据库并在上面工作?如何列出某个数据库内所有表?如何获取表内所有 Field 对象的名称和类型?
- mysql -u -p
- show databases;
- use dbname;
- show tables;
- describe table_name ;
#Java 编程题
一个数如果恰好等于它的因子之和,这个数就称为「完数」。例如 6=1+2+3 .编程找出 1000 以内的所有完数。
package test;
/**
-
完数判断
-
@author CUI
/
public class Tl5 {
/*- 判断是否是完数
- @param a 需判断的数字
- @return boolean
*/
public static boolean test(int a) {
int cup = 0;
// 循环遍历,找到所有因子,并计算因子之和
for (int i = 1; i < a; i++) {
if (a % i == 0)
cup = cup + i;
}
return (cup == a);
}
public static void main(String[] args) {
String str = “”;
for (int i = 1; i < 1000; i++) {
if (test(i)) {
str += i + “,”;
}
}
System.out.print(str.substring(0, str.length() - 1));
}
}