把一段字符串用“右起竖排”的古文格式输出。
using System; using System.Linq; namespace ConTest { class Program { static void Print(string text, int offset) { var matrix = text .Select((c, i) => new { Char = c, Index = i }) .GroupBy(c => c.Index % offset, c => c.Char.ToString()); Array.ForEach( matrix.ToArray(), a => Console.WriteLine(String.Join("|", a.Reverse().ToArray()))); } static void Main(string[] args) { Print("床前明月光疑是地上霜举头望明月低头思故乡",5); Console.Read(); } } }