Rotate [1..7] right by 3 positions; print space-separated.
| Test | Status | Details |
|---|
Ready — edit the code above and click Run or Submit.
using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main()
{
int[] a = { 1, 2, 3, 4, 5, 6, 7 };
int k = 3 % a.Length;
Array.Reverse(a); Array.Reverse(a, 0, k); Array.Reverse(a, k, a.Length - k);
Console.WriteLine(string.Join(" ", a));
}
}
Try solving on your own first, then reveal the official answer.
Triple-reverse rotation trick.