ntodorova

28.12-02.Anaccil

Dec 31st, 2012
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. class Anacci
  4. {
  5.     static void Main()
  6.     {
  7.         char firstLetter = char.Parse(Console.ReadLine());
  8.         char secondLetter = char.Parse(Console.ReadLine());
  9.  
  10.         byte L = byte.Parse(Console.ReadLine());
  11.  
  12.         int firstIndex = (int)firstLetter - 64;
  13.         int secondIndex = (int)secondLetter - 64;
  14.  
  15.         Console.WriteLine((char)(firstIndex + 64));
  16.  
  17.         if (L != 1)
  18.         {
  19.             for (int i = 1; i < L; i++)
  20.             {
  21.                 for (int j = 0; j <= 1; j++)
  22.                 {
  23.                     int newIndex = firstIndex + secondIndex;
  24.  
  25.                     if (newIndex > 26)
  26.                     {
  27.                         newIndex %= 26;
  28.                     }
  29.  
  30.                     firstIndex = secondIndex;
  31.                     secondIndex = newIndex;
  32.  
  33.                     if (j > 0) {
  34.                         string whitespaces = new string(' ', i - 1);
  35.                         Console.Write(whitespaces);
  36.                     }
  37.  
  38.                     Console.Write((char)(firstIndex + 64));
  39.                 }
  40.  
  41.                 Console.WriteLine();
  42.             }
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment