printf格式输出数字,位数不够前面补0,适用与输出编号 printf格式输出:%[flags][width][.perc][F|N|h|l]type 用到了flags中的 0 (注意是零不是欧) ,其百科描述为:将输出的前面补上0,直到占满指定列宽为止(不可以搭配使用-) width 即表示需要输出的位数. int a = 4; printf("%03d",a); 输出:004 也可以用 * 代替位数,在后面的参数列表中用变量控制输出位数: int a = 4; int n = 3…
import java.util.ArrayList; import java.util.Scanner; public class Text { @SuppressWarnings("resource") public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int M = scanner.nextInt();//M代表输入的M串字符串 int N=scanner.next…
oracle在使用函数计算式会遇到这样的情况:例如sum函数 如果计算的sum值为null,则用0替代 方法1(便于理解): select when sum(c.num) is null then 0 else sum(t.num) from class c 方法2(简单粗暴): NVL(Expr1,Expr2)如果Expr1为NULL,返回Expr2的值,否则返回Expr1的值 select NVL(SUM(c.num) ,0) from class c…