Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace apps
- {
- class Program
- {
- static void Main()
- {
- //append arrays
- string input = Console.ReadLine();
- input = RemoveWhitespace(input); //remove whitespaces
- List<string> arrays= input.Split('|').ToList(); // split into arrays
- for (int i = arrays.Count - 1; i >= 0; i--)
- {// print in reverse order
- string CurrentString = arrays[i];
- string newstring = string.Empty;
- for (int x = 0; x < CurrentString.Length; x++)
- {
- if (CurrentString[x] == '-') { newstring += "-"; }
- else
- {
- newstring += CurrentString[x] + " ";
- }
- }
- CurrentString = newstring;
- Console.Write(CurrentString);
- }
- }
- static string RemoveWhitespace(string input)
- {
- string newstring = string.Empty;
- foreach(char c in input)
- {
- if (c !=' ') { newstring += c.ToString(); }
- }
- return newstring;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement