50,749
社区成员
发帖
与我相关
我的任务
分享
public static void main(String[] args) {
int i = 12578;
int count=1;
//为了方便遍历
HashMap<Integer,Integer> map = new HashMap<>();
// 数数
while(i != 98752) {
String s ="";
s+=i;
// 正则: 不能重复,不能是0346 ,长度等于5
if(s.matches("(?!\\d*(\\d)\\d*\\1\\d*)[^0346]{5}")) {
if(Integer.parseInt(s)%75 == 0) {
int num = Integer.parseInt(s);
map.put(count, num);
count++;
}
}
i++;
}
//遍历
for (Integer key : map.keySet()) {
System.out.println("第"+key+"个是"+map.get(key));
}
}
}
public static void main(String[] args) {
int i = 12578;
int count=1;
//为了方便遍历
HashMap<Integer,Integer> map = new HashMap<>();
// 数数
while(i != 98752) {
String s ="";
s+=i;
// 正则: 不能重复,不能是0346 ,长度等于5
if(s.matches("(?!\\d*(\\d)\\d*\\1\\d*)[^0346]{5}")) {
if(Integer.parseInt(s)%75 == 0) {
int num = Integer.parseInt(s);
map.put(count, num);
count++;
}
}
i++;
}
//遍历
for (Integer key : map.keySet()) {
System.out.println("第"+key+"个是"+map.get(key));
}
}
private static boolean matched(String content){
if (content.contains("0")) return false;
String regEx = "(?!\\d*(\\d)\\d*\\1\\d*)\\d{5}";
Pattern p = Pattern.compile(regEx);
Matcher m = p.matcher(content);
return m.find();
}
public static void main(String[] args){
int l = 10000/75;
int h = 99999/75;
int result;
for(int i=l; i<=h; i++){
result = i*75;
String tmp = String.format("%d", result);
if (matched(tmp)) System.out.println(tmp+":matched");
else System.out.println(tmp+":not matched");
}
}