using System; using System; class StringReverser{ static void Main(string[] args) { Console.WriteLine("Enter text (press enter twice to get the reverse):"); string input = ReadMultiLine(); // get the input string //Console.WriteLine("Your String:\n " + input); string[] lines = input.Split('\n'); foreach(string line in lines) { string[] subs = line.Split(' '); Array.Reverse(subs); // reverse the order of the words string output = string.Join(" ", subs); // join the words back into a string Console.WriteLine(output); // reversed string } } static string ReadMultiLine() { string userInput = ""; string line; // Read lines of text from the console until the user presses enter twice while ((line = Console.ReadLine()) != null ) { if (line.Length == 0) { break; } userInput += line + "\n"; } return userInput; } }