Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace ConsoleApp1
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. string input = Console.ReadLine();
  11.  
  12. string[] words = input
  13. .Split(new[] { '.', ',', '!', '?', '-', ' ' }, StringSplitOptions.RemoveEmptyEntries);
  14. Stack<string> reversedSentence = new Stack<string>();
  15.  
  16. foreach (var item in words)
  17. {
  18. reversedSentence.Push(item);
  19. }
  20. while (reversedSentence.Count>0)
  21. {
  22. Console.WriteLine(reversedSentence.Pop());
  23. }
  24.  
  25.  
  26.  
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement