Advertisement
Guest User

Untitled

a guest
May 19th, 2015
703
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.46 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class StringMatrixRotations
  6. {
  7.     static void Main()
  8.     {
  9.         string rotate = Console.ReadLine();
  10.         string[] integer = rotate.Split('(');
  11.         integer[1] = integer[1].Remove(integer[1].Length - 1, 1);
  12.         int degrees = int.Parse(integer[1]);
  13.         string text = Console.ReadLine();
  14.         List<string> input = new List<string>();
  15.         int longestWord = 0;
  16.  
  17.         while (text != "END")
  18.         {
  19.             input.Add(text);
  20.             if (longestWord < text.Length)
  21.             {
  22.                 longestWord = text.Length;
  23.             }
  24.             text = Console.ReadLine();
  25.         }
  26.  
  27.         for (int i = 0; i < input.Count; i++)
  28.         {
  29.             if (input[i].Length < longestWord)
  30.             {
  31.                 input[i] = input[i] + new string(' ', longestWord - input[i].Length);
  32.             }
  33.         }
  34.  
  35.         if (degrees == 180 || degrees % 360 == 180)
  36.         {
  37.             for (int i = input.Count - 1; i >= 0; i--)
  38.             {
  39.                 for (int j = input[i].Length - 1; j >= 0; j--)
  40.                 {
  41.                     Console.Write(input[i][j]);
  42.                 }
  43.                 Console.WriteLine();
  44.             }
  45.         }
  46.  
  47.         char[,] rotate90 = new char[longestWord, input.Count];
  48.  
  49.         for (int row = 0; row < longestWord; row++)
  50.         {
  51.             for (int col = 0; col < input.Count; col++)
  52.             {
  53.                 rotate90[row, col] = input[col][row];
  54.             }
  55.         }
  56.  
  57.         if (degrees == 270 || degrees % 360 == 270)
  58.         {
  59.  
  60.             for (int i = rotate90.GetLength(0) - 1; i >= 0; i--)
  61.             {
  62.                 for (int j = 0; j < rotate90.GetLength(1); j++)
  63.                 {
  64.                     Console.Write(rotate90[i, j]);
  65.                 }
  66.                 Console.WriteLine();
  67.             }
  68.         }
  69.  
  70.         if (degrees == 90 || degrees % 360 == 90)
  71.         {
  72.             for (int i = 0; i < rotate90.GetLength(0); i++)
  73.             {
  74.                 for (int j = rotate90.GetLength(1) - 1; j >= 0; j--)
  75.                 {
  76.                     Console.Write(rotate90[i, j]);
  77.                 }
  78.                 Console.WriteLine();
  79.             }
  80.         }
  81.  
  82.         if (degrees == 0 || degrees % 360 == 0)
  83.         {
  84.             foreach (var rotate360 in input)
  85.             {
  86.                 Console.WriteLine(rotate360);
  87.             }
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement