Write a program that takes data, a word at a time and reverses the words of the line. Sample input/output dialogue: Input string value: birds and bees
Reversed: bees and birds
using System;
namespace Test
{
class ReverseTest
{
static void Main()
{
Console.Write("Input string value: ");
string line = Console.ReadLine();
string[] words = line.Split(new char[] {' ', '\t'});
Console.Write("Reversed:");
for(int i = words.Length - 1; i >= 0; --i)
{
Console.Write(" " + words[i]);
}
Console.WriteLine();
}
}
}
Comments
Leave a comment