📄 checkjianhao.java
字号:
package com.zx.dangangl;
public class CheckJianHao {
/**
* (用java编写测试通过,然后改为javascript的.)
* 检查件号是否是连续的,如果是返回true,否,返回false。
* @param jh 数字组成的字符串数组。
* @return boolean 。true表示件号是连续的,false表示件号是不连续的。
*/
public static boolean checkJianHao(String[] jh){
if(jh==null) return false;
int LEN = jh.length;
int[] tempIntJh = new int[LEN];//初始化一个临时的整形数组
for(int i=0;i<LEN;i++){
tempIntJh[i]=Integer.parseInt(jh[i]);
}
int flag = tempIntJh[0]; //
boolean result = true;
for(int i=0;i<LEN;i++){
if(tempIntJh[i]==flag){
flag ++;
continue;
}else{
result = false;
break;
}
}
return result;
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//String[] jh = new String[]{"2","3","4","6",};
// String[] jh = new String[]{"2","3","4","5",};
// String[] jh = new String[]{"2","3"};
String[] jh = new String[]{"2"};
System.out.print(checkJianHao(jh));
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -