回転のアルゴリズム

全然、日記を更新できないので一発ネタなどを。知っている人は知っていると思いますが。(^^;

using System;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string args)
    {
        int nums = { 1, 2, 3, 4, 5, 6, 7, 8, 9 };

        // 回転
        // 2,3,4,5,6,7,8,9,1
        // 3,4,5,6,7,8,9,1,2
        // 4,5,6,7,8,9,1,2,3
        // ...

        // 5回転させる
        int index = 5;
        Array.Reverse(nums, 0, index);
        Array.Reverse(nums, index, nums.Length - index);
        Array.Reverse(nums);

        foreach (int n in nums)
            Console.Write("{0},", n);
        Console.WriteLine();
    }
}

/*
6,7,8,9,1,2,3,4,5,
 */

Reverse3連打で回転します。