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 Program
- {
- static void Main(string[] args)
- {
- List<string> inputText = Console.ReadLine()
- .Split(new char[] { ',', ';', ':', '.', '!', '(', ')',
- '"', '\\', '/', '[', ']', ' ' },
- StringSplitOptions.RemoveEmptyEntries)
- .ToList();
- List<string> lowerCase = new List<string>();
- List<string> upperCase = new List<string>();
- List<string> mixedCase = new List<string>();
- for(int i =0; i<inputText.Count; i++)
- {
- string result =GetData(inputText[i]);
- switch (result)
- {
- case "lower": lowerCase.Add(inputText[i]); break;
- case "upper": upperCase.Add(inputText[i]); break;
- case "mixed": mixedCase.Add(inputText[i]); break;
- }
- }
- Console.WriteLine("Lower-case: {0}",string.Join(", ", lowerCase));
- Console.WriteLine("Mixed-case: {0}",string.Join(", ", mixedCase));
- Console.WriteLine("Upper-case: {0}", string.Join(", ", upperCase));
- }
- private static string GetData(string element)
- {
- string typeIs = string.Empty;
- if (element[0]>='a' && element[0] <= 'z') typeIs="lower";
- else if (element[0]>='A' && element[0] <= 'Z') typeIs="upper";
- else typeIs="mixed";
- for (int i=1; i<element.Length; i++)
- {
- if (element[i] >= 'a' && element[i] <= 'z'
- && typeIs == "lower") typeIs = "lower";
- else if (element[i] >= 'A' && element[i] <= 'Z'
- && typeIs == "upper") typeIs = "upper";
- else
- {
- typeIs = "mixed";
- break;
- }
- }
- return typeIs;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment