AcWing 1519. 密码+JAVA
原题链接
简单
作者:
xiaozuo99
,
2021-03-18 23:35:50
,
所有人可见
,
阅读 260
import java.util.Scanner;
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = n;
int cnt = 0;
LinkedHashMap<String,String> lhm = new LinkedHashMap();
while(m-- != 0){
String a = sc.next();
String b = sc.next();
char[] c = b.toCharArray();
boolean flag = false;
for(int i = 0;i<c.length;i++){
if(c[i] == '1') {
c[i] = '@';
flag = true;
} else if(c[i] == '0') {
c[i] = '%';
flag = true;
} else if(c[i] == 'l') {
c[i] = 'L';
flag = true;
} else if(c[i] == 'O') {
c[i] = 'o';
flag = true;
}
}
if(!flag){ // 如果一个都没有改的话
cnt++;
}else{
lhm.put(a,String.valueOf(c));
}
}
if(lhm.size() != 0){
System.out.println(lhm.size());
Iterator it = lhm.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry) it.next();
System.out.println( entry.getKey() + " " + entry.getValue());
}
}else if(n == 1){
System.out.println("There is " +n+" account and no account is modified");
}else{
System.out.println("There are " +n+" accounts and no account is modified");
}
}
}
我的代码也很长