Advertisement
bomman

Matrix of Palindromes

Jun 5th, 2016
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. namespace _2.Matrix_of_Palindromes
  2. {
  3.     using System;
  4.     using System.Linq;
  5.     using System.Text;
  6.  
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             int[] limitations = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  12.             int rows = limitations[0];
  13.             int cols = limitations[1];
  14.  
  15.             StringBuilder output = new StringBuilder();
  16.             for (int row = 0; row < rows; row++)
  17.             {
  18.                 char firstLetter = (char) ('a' + row);
  19.                 for (int col = 0; col < cols; col++)
  20.                 {
  21.                     output.AppendFormat("{0}{1}{2} ", firstLetter, (char) (firstLetter + col), firstLetter);
  22.                 }
  23.  
  24.                 output.AppendLine();
  25.             }
  26.  
  27.             Console.WriteLine(output.ToString().Trim());
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement