Advertisement
Assi

13. Strings and Text Processing 24. SortWords

Feb 3rd, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.44 KB | None | 0 0
  1. using System;
  2.  
  3. class SortWords
  4. {
  5.     static void Main()
  6.     {
  7.         string str = "Write a program that reads a list of words, separated by spaces and prints the list in an alphabetical order.";
  8.  
  9.         string[] words = str.Split(new char[] { ' ', ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
  10.         Array.Sort(words);
  11.  
  12.         foreach (var word in words)
  13.         {
  14.             Console.WriteLine(word);
  15.         }
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement