Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Linq;
- using System.Text.RegularExpressions;
- namespace lab
- {
- class Program
- {
- static bool hasDoubleNonVowel(string s)
- {
- char prev = '0';
- foreach (var c in s)
- {
- if ("aAoOuUiIeE".IndexOf(c) == -1)
- {
- if (c == prev) return true;
- prev = c;
- }
- else prev = '0';
- }
- return false;
- }
- static void Main(string[] args)
- {
- string text = File.ReadAllText(@"D://Projects//univ//sp//laba1//lab//lab//input.txt");
- text.Split(' ').Select(s => Regex.Replace(s, "[^0-9a-zA-Z]", "")) // Split and remove special symbols
- .Where(hasDoubleNonVowel) // Check 2 nonvowel
- .Distinct() // No duplicates
- .AsParallel().ForAll(s => Console.WriteLine(s)); // Output
- Console.ReadKey();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement