awuli纯纯啊 @ 2019-01-17 17:58:00
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner r=new Scanner(System.in);
int n=r.nextInt();
String str="qwe";
String[] arr = str.split("");
String mod[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
for(int i=0;i<3;i++) {
for(int j=0;j<26;j++) {
if(arr[i]==mod[j]) {
if(j+n>=26) arr[i]=mod[j+n-26];
else arr[i]=mod[j+n];
}
}
}
}
} 实在不明白为什么arr【】数组的值没有发生改变
by t162 @ 2019-01-17 18:03:22
toCharArray()+valueOf()了解一下
by 33028120040712wcl @ 2019-01-17 18:05:17
希望更丰富的展现?使用Markdown
by t162 @ 2019-01-17 18:07:56
用equals()
方法。。。==
比较的是他们的地址,当然是错的了。。。
by t162 @ 2019-01-17 18:09:51
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner r=new Scanner(System.in);
int n=r.nextInt();
String str="qwe";
String[] arr = str.split("");
String mod[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
for(int i=0;i<3;i++) {
for(int j=0;j<26;j++) {
if(arr[i].equals(mod[j])) {
if(j+n>=26) arr[i]=mod[j+n-26];
else arr[i]=mod[j+n];
}
}
}
}
}