Advertisement
Guest User

Untitled

a guest
Jun 5th, 2016
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _06.Reverse_Words_in_Sentence
  6. {
  7.     class Program
  8.     {
  9.         static void Main()
  10.         {
  11.             string text = Console.ReadLine();
  12.             char[] separators = { '.', ',', ':', ';', '=', '(', ')', '&', '[', ']', '\"', '\'', '\\', '/', '!', '?', ' ' };
  13.             List<string> list = text.Split(separators, StringSplitOptions.RemoveEmptyEntries).ToList();
  14.             list.Reverse();
  15.             List<string> tempList = new List<string>(list);
  16.             tempList.Sort((e1, e2) => e2.Length.CompareTo(e1.Length));
  17.             List<string> sep = text.Split(tempList.ToArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
  18.             for (int i = 0; i < list.Count; i++)
  19.             {
  20.                 Console.Write(list[i] + sep[i]);
  21.             }
  22.         }
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement