Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- namespace _2chSolver
- {
- class Program
- {
- //Eng 97 122
- //Rus 1072 1103
- private static readonly char[] Vowels = new [] { 'a', 'e', 'y', 'u', 'i', 'o', 'а', 'у', 'е', 'э', 'о', 'ы', 'я', 'и', 'ю' };
- private enum PreviousCharType
- {
- Consonant,
- Vowel,
- None
- }
- static void Main(string[] args)
- {
- int rus = 0;
- int eng = 0;
- int vowels = 0;
- int consonantsAfterVowels = 0;
- int vowelsAfterConsonants = 0;
- PreviousCharType prevCharType = PreviousCharType.None;
- using (var reader = new StreamReader("input.txt"))
- {
- do
- {
- var ch = Char.ToLower((char) reader.Read());
- var currentCharType = PreviousCharType.None;
- if (ch <= 122 && ch >= 97)
- {
- eng++;
- currentCharType = PreviousCharType.Consonant;
- }
- if (ch <= 1103 && ch >= 1072)
- {
- rus++;
- currentCharType = PreviousCharType.Consonant;
- }
- if (Vowels.Contains(ch))
- {
- vowels++;
- currentCharType = PreviousCharType.Vowel;
- }
- if (prevCharType == PreviousCharType.Consonant && currentCharType == PreviousCharType.Vowel)
- {
- vowelsAfterConsonants++;
- }
- if (prevCharType == PreviousCharType.Vowel && currentCharType == PreviousCharType.Consonant)
- {
- consonantsAfterVowels++;
- }
- prevCharType = currentCharType;
- }
- while (!reader.EndOfStream);
- Console.WriteLine("Results");
- Console.WriteLine($"Rus: {rus}");
- Console.WriteLine($"Eng: {eng}");
- Console.WriteLine($"Vowels: {vowels * 1.0 / (rus + eng) * 100} %");
- Console.WriteLine($"Consonants: {(rus + eng - vowels) * 1.0 / (rus + eng) * 100} %");
- Console.WriteLine($"VowelsAfterConsonants: {vowelsAfterConsonants}");
- Console.WriteLine($"ConsonantsAfterVowels: {consonantsAfterVowels}");
- Console.ReadKey();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment