using System;
using System.Text;
namespace ConsoleApplication_C_Sharp
{
class Program
{
static void Main(string[] args)
{
string s = "java\n" +
"c\n" +
"php\n" +
"python";
s = reverseWords(s);
Console.WriteLine(s);
}
public static string reverseWords(string s)
{
StringBuilder sb = new StringBuilder();
char[] sp = {'\n', '\r'};
string[] arr = s.Split(sp);
for (int i = arr.Length - 1; i >= 0; i--) {
String[] words = arr[i].Split(' ');
for (int j = words.Length - 1; j >= 0; j--) {
sb.Append(words[j]).Append(" ");
}
sb.Append("\n");
}
return sb.ToString();
}
}
}
/*
run:
python
php
c
java
*/