Advertisement
Guest User

pes

a guest
Oct 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Text.RegularExpressions;
  5.  
  6. namespace lab
  7. {
  8.     class Program
  9.     {
  10.         static bool hasDoubleNonVowel(string s)
  11.         {
  12.             char prev = '0';
  13.             foreach (var c in s)
  14.             {
  15.                 if ("aAoOuUiIeE".IndexOf(c) == -1)
  16.                 {
  17.                     if (c == prev) return true;
  18.                     prev = c;
  19.                 }
  20.                 else prev = '0';
  21.             }
  22.             return false;
  23.         }
  24.  
  25.         static void Main(string[] args)
  26.         {
  27.             string text = File.ReadAllText(@"D://Projects//univ//sp//laba1//lab//lab//input.txt");
  28.             text.Split(' ').Select(s => Regex.Replace(s, "[^0-9a-zA-Z]", "")) // Split and remove special symbols
  29.                 .Where(hasDoubleNonVowel) // Check 2 nonvowel
  30.                 .Distinct() // No duplicates
  31.                 .AsParallel().ForAll(s => Console.WriteLine(s)); // Output
  32.             Console.ReadKey();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement