Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- public class Program
- {
- public static void Main()
- {
- string input = Console.ReadLine();
- int degrees = int.Parse(Regex.Replace(input, "\\D+", "")) % 360;
- var lines = ReadLines();
- int maxLength = lines.Max(l => l.Length);
- int symbolsPerLine = degrees % 180 == 0 ? maxLength : lines.Count;
- int linesCount = degrees % 180 == 0 ? lines.Count : maxLength;
- lines = lines
- .Select(l => degrees == 180 || degrees == 270 ? ReverseString(l).PadLeft(maxLength) : l.PadRight(maxLength))
- .ToList();
- if (degrees == 90 || degrees == 180)
- {
- lines.Reverse();
- }
- StringBuilder output = new StringBuilder(symbolsPerLine * lines.Count);
- for (int i = 0; i < linesCount; i++)
- {
- for (int j = 0; j < symbolsPerLine; j++)
- {
- output.Append(degrees % 180 == 0 ? lines[i][j] : lines[j][i]);
- }
- output.AppendLine();
- }
- Console.WriteLine(output.ToString());
- }
- private static List<string> ReadLines()
- {
- List<string> lines = new List<string>();
- string input;
- while (!(input = Console.ReadLine()).Equals("END"))
- {
- lines.Add(input);
- }
- return lines;
- }
- private static string ReverseString(string s)
- {
- char[] symbols = s.ToCharArray();
- Array.Reverse(symbols);
- return new string(symbols);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement