class Program
{
static int k;
static string[] SToArray(string str)
{
int size = 1;
for (int i = 0; i < str.Length; i++)
{
if (str[i] == ' ')
size++;
}
string str1 = "";
string[] sa = new string[size];
for (int i = 0; i < str.Length; i++)
{
if (str[i] == ' ')
{
sa[k] = str1;
str1 = "";
k++;
}
else
str1 += str[i];
if (i == str.Length - 1)
sa[k] = str1;
}
return sa;
}
static void Main()
{
Console.WriteLine("Enter the
string: ");
string input =
Console.ReadLine();
string[] revers = SToArray(input);
foreach (string item in revers)
{
for (int i = item.Length - 1; i >= 0; i--)
{
Console.Write(item[i]);
}
Console.Write(" ");
}
Console.ReadLine();
}
}
Output:
No comments:
Post a Comment