andy6804tw
8/16/2016 - 2:02 AM

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=8314 這題這題會給五組資訊每一組有兩個數字分別為更改位置的索引值以及左移或右移的數目 當(索引值+上位移數)%26小於0要加回26,並且位移的對象為

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=8314

這題這題會給五組資訊每一組有兩個數字分別為更改位置的索引值以及左移或右移的數目 當(索引值+上位移數)%26小於0要加回26,並且位移的對象為az所以要建立兩個az陣列一個是原本乾淨沒位移過的一個是放答案的陣列

import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char ary[]="abcdefghijklmnopqrstuvwxyz".toCharArray(),arr[]="abcdefghijklmnopqrstuvwxyz".toCharArray();
		for(int i=0;i<5;i++){
			int index=scn.nextInt(),num=scn.nextInt(),tot=((num+index)%26);
			if(tot<0)
				tot+=26;
			arr[index]=ary[tot];
		}
		for(char c:arr)
			System.out.print(c);
		System.out.println();
	}
	/* 
    題目:[C_ST59-易] 字串旋轉運算
    作者:1010
    時間:西元 2016 年 8 月 */
}