首頁  >  文章  >  資料庫  >  把字符串abcdef旋转2位得到字符串cdefab

把字符串abcdef旋转2位得到字符串cdefab

WBOY
WBOY原創
2016-06-07 15:43:021573瀏覽

public class RightShift { public static void main(String args[]) { char[] c = { 'a', 'b', 'c', 'd', 'e' }; for (int i = 0; i c.length; i) { System.out.print(c[i]); } for (int i = 0; i 2; i) { char temp = c[0]; for (int j = 0; j c.length -

public class RightShift {

 public static void main(String args[]) {

  char[] c = { 'a', 'b', 'c', 'd', 'e' };

  for (int i = 0; i    System.out.print(c[i]);
  }

  for (int i = 0; i    char temp = c[0];
   for (int j = 0; j     c[j] = c[j + 1];
   }
   c[c.length - 1] = temp;
  }
  System.out.println();
  for (int i = 0; i    System.out.print(c[i]);
  }
 }

}

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn