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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Ramesh MaruthiRank #937 · 2.2K reputationPosted Aug 24, 2015, 10:53 AM EDT
{
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 KRank #554 · 4.4K reputationPosted Aug 24, 2015, 7:47 PM EDT
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