题解 | #字符串加密#
字符串加密
https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3
import java.util.*; public class Main { public static void main(String[] args) { Scanner fzhinput = new Scanner(System.in); String key = fzhinput.nextLine(); List<String> xghzmb = new ArrayList<>(); List<String> zmb = new ArrayList<>(); int num; for(char c='a';c<='z';c++){ zmb.add(Character.toString(c)); } for(int i=0;i<key.length();i++){ if(!xghzmb.contains(Character.toString(key.charAt(i)))){ xghzmb.add(Character.toString(key.charAt(i))); } } for(char c='a';c<='z';c++){ if(!xghzmb.contains(Character.toString(c))){ xghzmb.add(Character.toString(c)); } } String dclpassword = fzhinput.nextLine(); for(int i=0;i<dclpassword.length();i++){ char ch = dclpassword.charAt(i); num=0; for(String s: zmb){ if(Character.toString(ch).equals(s)){ break; } num++; } System.out.print(xghzmb.get(num)); } } }