Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class RotateList {
- public static void main(String[] args) {
- Scanner myScan = new Scanner(System.in);
- String[] list = myScan.nextLine().split(",");
- int n = Integer.parseInt(myScan.nextLine());
- for (int i = 0; i < n; i++) {
- String[] rotateList = new String[list.length];
- for (int j = 1; j < list.length; j++) {
- rotateList[j - 1] = list[j];
- }
- rotateList[list.length - 1] = list[0];
- for (int j = 0; j < list.length; j++) {
- list[j] = rotateList[j];
- }
- }
- System.out.println(String.join(",", list));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment