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 SplitWordCas_24._05._2016
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[] separators = { ',', ';', ':', '.', '!', ' ' };
- List<string> words = Console.ReadLine().Split(separators, StringSplitOptions.RemoveEmptyEntries).ToList();
- List<string> lowerCaseWords = IsLowerCase(separators, words);
- List<string> upperCaseWords = IsUpperCase(separators, words);
- List<string> mixedCaseWords = IsMixedCase(separators, words);
- Console.WriteLine("Lower-case: {0}", string.Join(", ", lowerCaseWords));
- Console.WriteLine("Mixed-case: {0}", string.Join(", ", mixedCaseWords));
- Console.WriteLine("Upper-case: {0}", string.Join(", ", upperCaseWords));
- }
- static List<string> IsMixedCase(char[] separators, List<string> words)
- {
- List<string> mixedCaseWords = new List<string>();
- foreach (string word in words)
- {
- int upperCaseLetters = 0;
- int lowerCaseLetters = 0;
- foreach (char letter in word)
- {
- if (char.IsUpper(letter))
- {
- upperCaseLetters++;
- }
- else if (char.IsLower(letter))
- {
- lowerCaseLetters++;
- }
- }
- if (upperCaseLetters != word.Length && lowerCaseLetters != word.Length)
- {
- mixedCaseWords.Add(word);
- }
- }
- return mixedCaseWords;
- }
- static List<string> IsUpperCase(char[] separators, List<string> words)
- {
- List<string> upperCaseWords = new List<string>();
- foreach(string word in words)
- {
- int upperCaseLetters = 0;
- foreach (char letter in word)
- {
- if (char.IsUpper(letter))
- {
- upperCaseLetters++;
- }
- else if (char.IsLower(letter))
- {
- break;
- }
- }
- if (upperCaseLetters == word.Length)
- {
- upperCaseWords.Add(word);
- }
- }
- return upperCaseWords;
- }
- static List<string> IsLowerCase(char[] separators, List<string> words)
- {
- List<string> lowerCaseWords = new List<string>();
- foreach (string word in words)
- {
- int lowerCaseLetters = 0;
- foreach (char letter in word)
- {
- if (char.IsLower(letter))
- {
- lowerCaseLetters++;
- }
- else if (char.IsUpper(letter))
- {
- break;
- }
- }
- if (lowerCaseLetters== word.Length)
- {
- lowerCaseWords.Add(word);
- }
- }
- return lowerCaseWords;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment