Advertisement
Guest User

Untitled

a guest
Sep 10th, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Application
  4. {
  5.     class Functions
  6.     {
  7.         public static int rotate(string[] args)
  8.         {
  9.             if (args.Length < 1) {
  10.                 Console.WriteLine("{0} args provided; expected {1}.",args.Length,1);
  11.                 return -1;
  12.             }
  13.  
  14.             int numberOfStrings;
  15.             if (!(int.TryParse(args[0], out numberOfStrings)))
  16.             {
  17.                 Console.WriteLine("First argument must be an integer.");
  18.                 return -1;
  19.             }
  20.             if (numberOfStrings != args.Length - 1)
  21.             {
  22.                 Console.WriteLine("{0} strings expected, but only {1} strings were found.",
  23.                     numberOfStrings, args.Length - 1);
  24.                 return -1;
  25.             }
  26.  
  27.             int is_max = 0;
  28.             for (int currentColumn = 1; currentColumn <= numberOfStrings; currentColumn++)
  29.             {
  30.                 string stringToRotate = args[currentColumn];
  31.                 char[] targetAsChars = stringToRotate.ToCharArray();
  32.                 if (targetAsChars.Length > is_max)
  33.                 {
  34.                     is_max = targetAsChars.Length;
  35.                 }
  36.                 for (int idx = 0; idx < targetAsChars.Length; idx++)
  37.                 {
  38.                     Console.CursorLeft = currentColumn - 1;
  39.                     Console.WriteLine(targetAsChars[idx]);
  40.                 }
  41.                 Console.CursorTop = Console.CursorTop - targetAsChars.Length;
  42.             }
  43.             Console.CursorTop = Console.CursorTop + is_max;
  44.             return 0;
  45.         }
  46.     }
  47.     class EntryPoint
  48.     {
  49.         static int Main(string[] args)
  50.         {
  51.             return Functions.rotate(args);
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement