Suppose if Input is : "Hello How Are You?"
Output Should be like this : "olleH woH erA ?uoY"
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Ramesh MaruthiPosted Aug 24, 2015, 2:53 PM
{
static void Main(string[] args)
{
string s = Convert.ToString(Console.ReadLine());
Program p = new Program();
string result = p.reverse(s);
Console.WriteLine("Result is {0}", result);
Console.ReadLine();
}
public string reverse(string s)
{
string[] arrays = s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
foreach(string word in arrays)
{
char[] arr = word.ToCharArray();
Array.Reverse(arr);
string rev = new string(arr);
arrays = arrays.Select(q => q.Replace(word, rev)).ToArray();
}
string reversedstring = string.Join(" ", arrays);
return reversedstring;
}
}
Karthikeyan KPosted Aug 24, 2015, 11:47 PM
string str = "Hello How Are You?";
string strrev = "";
foreach (var word in str.Split(' '))
{
string temp = "";
foreach (var ch in word.ToCharArray())
{
temp = ch + temp;
}
strrev = strrev + temp + "";
}
Console.WriteLine(strrev);
Kindly Accept my answer
Karthikeyan K