在一行上输入一个长度为
的字符串
,代表给定的密码。
在一行上输出一个字符串,代表变换后的密码。
NowCoder123
o69d6337123
直接输出
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String str = sc.nextLine();
if(str==null && str.length()==0)
return ;
for(int i=0;i<str.length();i++){
char temp =str.charAt(i);
if(temp>='0'&&temp<='9')
System.out.print(temp);
else if(temp>='a'&&temp<='c')
System.out.print(2);
else if(temp>='d'&&temp<='f')
System.out.print(3);
else if(temp>='g'&&temp<='i')
System.out.print(4);
else if(temp>='j'&&temp<='l')
System.out.print(5);
else if(temp>='m'&&temp<='o')
System.out.print(6);
else if(temp>='p'&&temp<='s')
System.out.print(7);
else if(temp>='t'&&temp<='v')
System.out.print(8);
else if(temp>='w'&&temp<='z')
System.out.print(9);
else if(temp>='A'&&temp<='Y')
System.out.print((char)(temp+32+1));
else if(temp=='Z')
System.out.print('a');
}
}
}
}
#include<iostream>
#include<string>
using namespace std;
const string dict1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
const string dict2="bcdefghijklmnopqrstuvwxyza22233344455566677778889999";
char Char_Change(char a){
for(int i=0;i<dict1.size();i++)
if(dict1[i]==a) return dict2[i];
return a;
}
int main(){
//string data="YUANzhi1987";
string data;
while(getline(cin,data)){
for(int i=0;i<data.size();i++)
data[i] = Char_Change(data[i]);
cout<<data<<endl;
}
return 0;
}
#include<iostream>
#include<string>
using namespace std;
//小写字母变换为九键键盘数字
char charToInt(const char& ch){
if('a'<=ch&&ch<='c') return '2';
else if('d'<=ch&&ch<='f') return '3';
else if('g'<=ch&&ch<='i') return '4';
else if('j'<=ch&&ch<='l') return '5';
else if('m'<=ch&&ch<='o') return '6';
else if('p'<=ch&&ch<='s') return '7';
else if('t'<=ch&&ch<='v') return '8';
else return '9';
}
//大写字母变为小写字母后往后移位
char charMove(const char& ch){
if(ch=='Z') return 'a';
else return tolower(ch)+1;
}
int main(){
string str;
while(getline(cin,str)){
string outStr;
for(auto ch:str){
if('a'<=ch&&ch<='z') outStr.push_back(charToInt(ch));
else if('A'<=ch&&ch<='Z') outStr.push_back(charMove(ch));
else outStr.push_back(ch);
}
cout<<outStr<<endl;
}
} def str_tran(get_str):
lst_str = []
for i in get_str:
lst_str.append(i)
for j in range(len(lst_str)):
if ord(lst_str[j]) == ord('Z'):
lst_str[j] = 'a'
elif ord(lst_str[j]) >= 65 and ord(lst_str[j]) < 90:
lst_str[j] = chr(ord(lst_str[j])+32+1)
elif lst_str[j] in 'abc':
lst_str[j] = '2'
elif lst_str[j] in 'def':
lst_str[j] = '3'
elif lst_str[j] in 'ghi':
lst_str[j] = '4'
elif lst_str[j] in 'jkl':
lst_str[j] = '5'
elif lst_str[j] in 'mno':
lst_str[j] = '6'
elif lst_str[j] in 'pqrs':
lst_str[j] = '7'
elif lst_str[j] in 'tuv':
lst_str[j] = '8'
elif lst_str[j] in 'wxyz':
lst_str[j] = '9'
return ''.join(lst_str)
get_str = input()
print(str_tran(get_str)) import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
char c[] = str.toCharArray();
for(int i = 0; i<str.length() ; i++){
if(c[i]>='A'&&c[i]<='Z'){
if(c[i]+32 != 'z')
c[i] += 33;
else
c[i] = 'a';
}
else if(c[i]=='a'||c[i]=='b'||c[i]=='c')
c[i]='2';
else if(c[i]=='d'||c[i]=='e'||c[i]=='f')
c[i]='3';
else if(c[i]=='g'||c[i]=='h'||c[i]=='i')
c[i]='4';
else if(c[i]=='j'||c[i]=='k'||c[i]=='l')
c[i]='5';
else if(c[i]=='m'||c[i]=='n'||c[i]=='o')
c[i]='6';
else if(c[i]=='p'||c[i]=='q'||c[i]=='r'||c[i]=='s')
c[i]='7';
else if(c[i]=='t'||c[i]=='u'||c[i]=='v')
c[i]='8';
else if(c[i]=='w'||c[i]=='x'||c[i]=='y'||c[i]=='z')
c[i]='9';
System.out.print(c[i]);
}
System.out.println();
}
}
#include<stdio.h>
int main(){
char c;
while(~scanf("%c",&c)){
if(c=='Z')
printf("a");
else if('A'<=c&&c<'Z')
printf("%c",c+33);
else if('a'<=c&&c<='z')
{
if('a'<=c&&c<='c') printf("2");
if('d'<=c&&c<='f') printf("3");
if('g'<=c&&c<='i') printf("4");
if('j'<=c&&c<='l') printf("5");
if('m'<=c&&c<='o') printf("6");
if('p'<=c&&c<='s') printf("7");
if('t'<=c&&c<='v') printf("8");
if('w'<=c&&c<='z') printf("9");
}
else printf("%c",c);
} printf("\n");
} number = {"2":"abc", "3":"def", "4":"ghi", "5":"jkl", "6":"mno", "7":"pqrs", "8":"tuv", "9":"wxyz"}
pw = list(input())
for i in range(len(pw)):
if pw[i].islower():
for key, value in number.items():
if pw[i] in value:
pw[i] = key
break
elif pw[i].isupper():
if pw[i] == "Z":
pw[i] = "a"
else:
pw[i] = chr(ord(pw[i].lower()) + 1)
print(*pw, sep="") a="abcdefghijklmnopqrstuvwxyza" w=input().strip() p="" for i in w: if i.islower(): if i in "abc": p+="2" elif i in "def": p+="3" elif i in "ghi": p+="4" elif i in "jkl": p+="5" elif i in "mno": p+="6" elif i in "pqrs": p+="7" elif i in "tuv": p+="8" elif i in "wxyz": p+="9" else: pass elif i.isupper(): inx=a.index(i.lower(),0,26) p+=a[inx+1] else: p+=i print(p)
import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String s = sc.nextLine();
StringBuilder sb = new StringBuilder();
for(int i=0; i<s.length(); i++){
sb.append(get(s.charAt(i)));
}
System.out.println(sb.toString());
}
}
private static char get(char c){
if(c>='A' && c<='Z'){//大写字母,变小写后移一位
if(c=='Z') return 'a';
return (char)(c+1+('a'-'A'));
}else if(c>='a' && c<='z'){//小写字母
// switch(c){
// case 'a':case'b':case'c': return '2';
// case 'd':case'e':case'f': return '3';
// case 'g':case'h':case'i': return '4';
// case 'j':case'k':case'l': return '5';
// case 'm':case'n':case'o': return '6';
// case 'p':case'q':case'r':case's': return '7';
// case 't':case'u':case'v': return '8';
// case 'w':case'x':case'y':case 'z': return '9';
// default: return ' ';
// }
String s = String.valueOf(c);
if("abc".contains(s)) return '2';
if("def".contains(s)) return '3';
if("ghi".contains(s)) return '4';
if("jkl".contains(s)) return '5';
if("mno".contains(s)) return '6';
if("pqrs".contains(s)) return '7';
if("tuv".contains(s)) return '8';
if("wxyz".contains(s)) return '9';
return ' ';
}else{//其他
return c;
}
}
} import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Decrypt {
public static final Map<Integer, String> MAP = new HashMap<>();
static {
MAP.put(2, "abc");
MAP.put(3, "def");
MAP.put(4, "ghi");
MAP.put(5, "jkl");
MAP.put(6, "mno");
MAP.put(7, "pqrs");
MAP.put(8, "tuv");
MAP.put(9, "wxyz");
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char[] pwds = sc.next().toCharArray();
String decyptedPwd = "";
int step = 32;
for (Character pwd : pwds) {
//大写字母范围
if (pwd >= 65 && pwd <= 90) {
if (pwd + step == 122) {
decyptedPwd += "a";
} else {
decyptedPwd += (char) ((pwd + step) + 1);
}
}else {
for (Map.Entry<Integer, String> map : MAP.entrySet()) {
if (map.getValue().contains(String.valueOf(pwd))) {
decyptedPwd += map.getKey();
}
}
if (!(pwd >= 97 && pwd <= 122)){
decyptedPwd+=pwd;
}
}
}
System.out.println(decyptedPwd);
}
}
mp = dict()
mp['0'] = '0'
mp['1'] = '1'
mp['a'] = '2'
mp['b'] = '2'
mp['c'] = '2'
mp['d'] = '3'
mp['e'] = '3'
mp['f'] = '3'
mp['g'] = '4'
mp['h'] = '4'
mp['i'] = '4'
mp['j'] = '5'
mp['k'] = '5'
mp['l'] = '5'
mp['m'] = '6'
mp['n'] = '6'
mp['o'] = '6'
mp['p'] = '7'
mp['q'] = '7'
mp['r'] = '7'
mp['s'] = '7'
mp['t'] = '8'
mp['u'] = '8'
mp['v'] = '8'
mp['w'] = '9'
mp['x'] = '9'
mp['y'] = '9'
mp['z'] = '9'
while True:
try:
trans = input().strip()
res = []
for i in range(len(trans)):
s = trans[i]
ascII = ord(s)
if ascII >= 65 and ascII <= 90:
if s == 'Z':
res.append('a')
else:
res.append(chr(ascII + 33))
elif ascII >= 97 and ascII <= 122:
res.append(mp[s])
else:
res.append(s)
print(''.join(res))
except:
break //穷举法 时间复杂度 0(n)
import java.util.*;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
//大写变成n+1的小写, 小写变为数字,数字还是数字
public static String value = "bcdefghijklmnopqrstuvwxyza222333444555666777788899990123456789";
public static String key = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
public static void main(String[] args) {
// System.out.println(key.length()+"-"+value.length());
Map<String,String> map = new HashMap();
for(int i = 0; i<key.length(); i++){
map.put(key.charAt(i)+"",value.charAt(i)+"");
}
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
StringBuffer sb = new StringBuffer();
while (in.hasNext()) { // 注意 while 处理多个 case
String a = in.next();
for(int i = 0; i<a.length(); i++){
sb.append(map.get(a.charAt(i)+""));
}
System.out.println(sb);
}
}
} #include<iostream>
#include <string>
using namespace std;
int main() {
string str;
while(cin >> str){
int len = str.size();
for(int i = 0; i<len ;i++){
if(str[i]>='A' && str[i]<'Z'){
str[i] = str[i] + 33;
continue; // continue必须加,否则后面继续转码
}
if(str[i] == 'Z'){
str[i] = 'a';
continue;
}
if(str[i]>='a' && str[i]<='c')
str[i] = '2';
if(str[i]>='d' && str[i]<='f')
str[i] = '3';
if(str[i]>='g' && str[i]<='i')
str[i] = '4';
if(str[i]>='j' && str[i]<='l')
str[i] = '5';
if(str[i]>='m' && str[i]<='o')
str[i] = '6';
if(str[i]>='p' && str[i]<='s')
str[i] = '7';
if(str[i]>='t' && str[i]<='v')
str[i] = '8';
if(str[i]>='w' && str[i]<='z')
str[i] = '9';
}
cout << str<< endl;
}
return 0;
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String string = sc.nextLine();
char[] chs = string.toCharArray();
String res = "";
for (int i = 0; i < chs.length ; i++) {
if(chs[i]>='a' && chs[i]<='z'){
res+=lowCase2digital(chs[i]);//小写变数字
}else if(chs[i]>='A' && chs[i]<='Z'){
res += UpCase2lowCase(chs[i]);
}else{
res += chs[i];
}
}
System.out.println(res);
}
}
public static char UpCase2lowCase(char c){
char tmp = (char) (c ^ ' ');
return (char)('a'+(tmp - 'a' + 1)%26);
}
public static char lowCase2digital(char c){
if(c>='a' && c<= 'c'){
return '2';
}else if(c>='d' && c<= 'f'){
return '3';
}else if(c>='g' && c<= 'i'){
return '4';
}else if(c>='j' && c<= 'l'){
return '5';
}else if(c>='m' && c<= 'o'){
return '6';
}else if(c>='p' && c<= 's'){
return '7';
}else if(c>='t' && c<= 'v'){
return '8';
}else{
return '9';
}
}
}
#include <bits/stdc++.h>
using namespace std;
int main(){
string a;
string b[8]={"abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
while(cin>>a){
for(int i=0;i<a.size();i++){
if(a[i]>='A'&&a[i]<='Z')
if(a[i]=='Z')
a[i]='a';
else
a[i]=tolower(a[i])+1;
else if(a[i]>='a'&&a[i]<='z'){
for(int j=0;j<8;j++){
if(b[j].find(a[i])!=b[j].npos)
a[i]=j+'2';
}
}
}
cout<<a<<endl;
}
return 0;
} import java.util.*;
public class Main{
public static void main(String[] args) {
Map<String, String> map = new HashMap<>();
map.put("abc", "2");
map.put("def", "3");
map.put("ghi", "4");
map.put("jkl", "5");
map.put("mno", "6");
map.put("pqrs", "7");
map.put("tuv", "8");
map.put("wxyz", "9");
Scanner scanner = new Scanner(System.in);
while (scanner.hasNext()) {
String line = scanner.nextLine();
char[] charArr = line.toCharArray();
StringBuilder stringBuilder = new StringBuilder();
for (char ch : charArr) {
if (ch >= 'A' && ch <= 'Y') {
String ss = String.valueOf((char) (ch + 1)).toLowerCase();
stringBuilder.append(ss);
} else if (ch == 'Z') {
stringBuilder.append('a');
} else if (ch >= 'a' && ch <= 'z') {
map.forEach((key, value) -> {
if (key.contains(String.valueOf(ch))) {
String ss = map.get(key);
stringBuilder.append(ss);
}
});
} else {
stringBuilder.append(ch);
}
}
System.out.println(stringBuilder.toString());
}
}
}
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while(sc.hasNext()){
String s = sc.nextLine();
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) >= 'A' && s.charAt(i) <= 'Z'){
String el = String.valueOf(s.charAt(i));
String s1 = el.toLowerCase();
char content;
if (s1.charAt(0) == 'z'){
content = 'a';
}else{
content = (char) (s1.charAt(0)+1);
}
stringBuffer.append(content);
}else if (s.charAt(i) >= 'a' && s.charAt(i) <= 'z'){
int content = 0;
char lower = s.charAt(i);
if (lower>= 'a' && lower <= 'c'){
content = 2;
}
if (lower>= 'd' && lower <= 'f'){
content = 3;
}
if (lower>= 'g' && lower <= 'i'){
content = 4;
}
if (lower>= 'j' && lower <= 'l'){
content = 5;
}
if (lower>= 'm' && lower <= 'o'){
content = 6;
}
if (lower>= 'p' && lower <= 's'){
content = 7;
}
if (lower>= 't' && lower <= 'v'){
content = 8;
}
if (lower>= 'w' && lower <= 'z'){
content = 9;
}
stringBuffer.append(content);
}else {
stringBuffer.append(s.charAt(i));
}
}
System.out.println(stringBuffer.toString());
}
}
}