Untitled

mail@pastecode.io avatar
unknown
plain_text
10 months ago
967 B
3
Indexable
Never
string[] newArray = Console.ReadLine().Split(' ');

        
        int rotations = int.Parse(Console.ReadLine());

        
        int[] numbers = new int[newArray.Length];
        for (int i = 0; i < newArray.Length; i++)
        {
            numbers[i] = int.Parse(newArray[i]);
        }

       
        for (int i = 0; i < rotations; i++)
        {
            
            int lastElement = numbers[numbers.Length - 1];

            
            for (int j = numbers.Length - 1; j > 0; j--)
            {
                numbers[j] = numbers[j - 1];
            }

            
            numbers[0] = lastElement;
        }

        
        for (int i = 0; i < numbers.Length; i++)
        {
            
            Console.Write(numbers[i]);

            
            if (i < numbers.Length - 1)
            {
                Console.Write(", ");
            }
        }

       
        Console.WriteLine();