public class CharacterShift {
/**
* @param args
*/
public static void main(String[] args) {
char[] word = "iphone".toCharArray();
int shift = 3;
char[] result = new char[word.length];
for (int k = 0; k < word.length; k++) {
int p = (k + shift) % word.length;
result[p] = word[k];
}
System.out.println(String.valueOf(word) + " shifted by " + shift + " becomes " + String.valueOf(result));
}
}
Mono Craters, Evening Cloudscape
19 hours ago
No comments:
Post a Comment