Advertisement
Guest User

Words

a guest
Feb 16th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Words
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var words = Console.ReadLine()
  14.                 .Split(new char[] { ' ', ':', ',', ';', ':', '.', '!', '(', ')', '"',
  15.                 '\'', '\\', '/', '[', ']' }, StringSplitOptions.RemoveEmptyEntries)
  16.                 .ToList();
  17.  
  18.             List<string> lowerCaseWords = new List<string>();
  19.             List<string> upperCaseWords = new List<string>();
  20.             List<string> mixedCaseWords = new List<string>();
  21.  
  22.             foreach (var word in words)
  23.             {
  24.                 bool isMixed = false;
  25.  
  26.                 for (int i = 0; i < word.Length; i++)
  27.                 {
  28.                     if (!Char.IsLetter(word[i]))
  29.                     {
  30.                         mixedCaseWords.Add(word);
  31.                         isMixed = true;
  32.                         break;
  33.                     }
  34.                 }
  35.                 if (isMixed == false && word == word.ToUpper())
  36.                 {
  37.                     upperCaseWords.Add(word);
  38.                 }
  39.                 else if (isMixed == false && word == word.ToLower())
  40.                 {
  41.                     lowerCaseWords.Add(word);
  42.                 }
  43.                 else if (isMixed == false)
  44.                 {
  45.                     mixedCaseWords.Add(word);
  46.                 }
  47.             }
  48.  
  49.             Console.WriteLine($"Lower-case: {string.Join(", ", lowerCaseWords)}");
  50.             Console.WriteLine($"Mixed-case: {string.Join(", ", mixedCaseWords)}");
  51.             Console.WriteLine($"Upper-case: {string.Join(", ", upperCaseWords)}");
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement