Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.Split_by_Word_Casing
- {
- class SplitByWordCasing
- {
- static void Main(string[] args)
- {
- char[] separators = new char[] { ',', ';', ':', '.', '!', '(', ')', '\'', '\'', '\\', '/', '[', ']', ' ' };
- List<string> words = Console.ReadLine()
- .Split(separators, StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- List<string> lowerCase = new List<string>();
- List<string> upperCase = new List<string>();
- List<string> mixedCase = new List<string>();
- foreach (var word in words)
- {
- if (isLower(word))
- {
- lowerCase.Add(word);
- }
- else if (isUpper(word))
- {
- upperCase.Add(word);
- }
- else
- {
- mixedCase.Add(word);
- }
- }
- Console.WriteLine("Lower-case: " + string.Join(", ", lowerCase));
- Console.WriteLine("Mixed-case: " + string.Join(", ", mixedCase));
- Console.WriteLine("Upper-case: " + string.Join(", ", upperCase));
- }
- public static bool isLower(string word)
- {
- foreach (var letter in word)
- {
- if (!Char.IsLower(letter))
- {
- return false;
- }
- }
- return true;
- }
- public static bool isUpper(string word)
- {
- foreach (var letter in word)
- {
- if (!Char.IsUpper(letter))
- {
- return false;
- }
- }
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement