Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace _04._Split_by_Word_Casing
- {
- class SplitByWord
- {
- static void Main(string[] args)
- {
- string[] words = Console.ReadLine()
- .Split(",;:.!()\"'\\/[] ".ToCharArray()
- ,StringSplitOptions.RemoveEmptyEntries);
- List<string> upperCase = new List<string>();
- List<string> lowerCase = new List<string>();
- List<string> mixed = new List<string>();
- foreach (var word in words)
- {
- if (IsUpperWord(word))
- {
- upperCase.Add(word);
- }
- else if (IsLowerWord(word))
- {
- lowerCase.Add(word);
- }
- else
- {
- mixed.Add(word);
- }
- }
- Console.WriteLine("Lower-case: {0}", string.Join(", ", lowerCase));
- Console.WriteLine("Mixed-case: {0}", string.Join(", ", mixed));
- Console.WriteLine("Upper-case: {0}", string.Join(", ", upperCase));
- }
- static bool IsUpperWord(string word)
- {
- foreach (char symbol in word)
- {
- if ('A' > symbol || symbol > 'Z')
- {
- return false;
- }
- }
- return true;
- }
- static bool IsLowerWord(string word)
- {
- foreach (char symbol in word)
- {
- if ('a' > symbol || symbol > 'z')
- {
- return false;
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment