Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace _04_Split_By_Word_Casing
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<string> input = Console.ReadLine().Split(new char[]
- { ',', ';', ':', '.', '!', '(', ')', '"', '\\', '/', '[', ']', ' ' },
- StringSplitOptions.RemoveEmptyEntries).ToList();
- List<string> lowerCase = new List<string>();
- List<string> mixedCase = new List<string>();
- List<string> upperCase = new List<string>();
- foreach (string word in input)
- {
- int lowerCaseLetters = 0;
- int upperCaseLetters = 0;
- foreach (char letter in word)
- {
- if (char.IsLower(letter))
- {
- lowerCaseLetters++;
- }
- else if (char.IsUpper(letter))
- {
- upperCaseLetters++;
- }
- }
- if (lowerCaseLetters != word.Length && upperCaseLetters != word.Length)
- {
- mixedCase.Add(word);
- }
- else if (lowerCaseLetters == word.Length)
- {
- lowerCase.Add(word);
- }
- else
- {
- upperCase.Add(word);
- }
- }
- Console.WriteLine("Lower-case: " + string.Join(", ", lowerCase));
- Console.WriteLine("Mixed-case: " + string.Join(", ", mixedCase));
- Console.WriteLine("Upper-case: " + string.Join(", ", upperCase));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement