stefan1919

Matrix of Palindromes

Aug 23rd, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int rows = int.Parse(Console.ReadLine());
  14.             int cols = int.Parse(Console.ReadLine());
  15.             char mainCharacter;
  16.             string alphabet1 = "abcdefghijklmnopqrstuvwxyz";
  17.             char[] alphabet = alphabet1.ToArray();
  18.             char helpCharacter;
  19.             string[,] matrix = new string[rows, cols];
  20.             string output = string.Empty;
  21.             for (int row = 0; row < matrix.GetLength(0); row++)
  22.             {
  23.                 for (int col = 0; col < matrix.GetLength(1); col++)
  24.                 {
  25.                     mainCharacter = alphabet[row];
  26.                     helpCharacter = alphabet[col + row];
  27.                     Console.Write("{0}{1}{2}{3}", mainCharacter, helpCharacter, mainCharacter, " ");
  28.                    
  29.                 }
  30.                 Console.WriteLine();
  31.             }
  32.  
  33.            
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment