赞
踩
目录
count(*) 是一定可以返回数值的,即使表为空,返回的也是 0.
max,t1 中没有数据会返回 null,col1全部都是 null 会返回 null。
concat 字符串拼接的其中一个字符串是 null,那么结果就是 null。
top 是 sql server 中的关键字,用于求前 n 条数据,
语法: select top n 查询字段 from ...
使用函数,就不会使用索引了,函数本身也会消耗时间。
hadoop 是属于大数据方向的数据库。
数据库事务四特性是:原子性,一致性,持续性,隔离性。
如图,画图之后发现就是斐波那契数,那就直接写即可。
代码实现:
- import java.util.Scanner;
-
- // 注意类名必须为 Main, 不要有任何 package xxx 信息
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- // 注意 hasNext 和 hasNextLine 的区别
- while (in.hasNextInt()) { // 注意 while 处理多个 case
- int n = in.nextInt();
- int count = fib(n);
- System.out.println(count);
- }
- }
-
- public static int fib(int n) {
- if (n == 1 || n == 2) return 1;
- return fib(n - 1) + fib(n - 2);
- }
- }
代码实现:
- import java.util.Scanner;
-
- // 注意类名必须为 Main, 不要有任何 package xxx 信息
- public class Main {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- // 注意 hasNext 和 hasNextLine 的区别
- while (in.hasNextLine()) { // 注意 while 处理多个 case
- String t = in.nextLine();// 通配符
- String s = in.nextLine();// 字符串
- System.out.println(match(t, s));
- }
- }
-
-
- public static boolean match(String tt, String ss) {
- // 动态规划
- char[] t = tt.toCharArray();
- char[] s = ss.toCharArray();
- // 通配符长度
- int tl = t.length;
- // 字符串长度
- int sl = s.length;
- // 多创建一个是为了避免数组越界
- boolean[][] dp = new boolean[sl + 1][tl + 1];
- // 初始化
- dp[0][0] = true;
- for (int i = 0; i <= sl; i++) {
- for (int j = 1; j <= tl; j++) {
- if (t[j - 1] == '*') {
- if (i == 0) {
- dp[i][j] = dp[i][j - 1];
- } else {
- if (s[i - 1] == '.'
- || (s[i - 1] >= 'a' && s[i - 1] <= 'z')
- || (s[i - 1] >= 'A' && s[i - 1] <= 'A')
- || ( s[i - 1] >= '0' && s[i - 1] <= '9') ) {
- dp[i][j] = dp[i][j - 1] || dp[i - 1][j];
- }
- }
- } else {
- // ? 字母数字 . 等
- if (i > 0 && defs(t[j - 1], s[i - 1])) {
- dp[i][j] = dp[i - 1][j - 1];
- }
- }
- }
- }
- return dp[sl][tl];
- }
-
-
- public static boolean defs(char t, char s) {
- if (t == '?') return true;
- if (t >= 'a' && t <= 'z') {
- t = (char)(t - 32);
- }
- if (s >= 'a' && s <= 'z') {
- s = (char)(s - 32);
- }
- return s == t;
- }
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。