Advertisement
neron476

строки_2_c_sharp

Sep 23rd, 2014
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace string_3_c_sharp
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12.  
  13.  
  14. Console.WriteLine("Введите строку");
  15. string originalLine = Console.ReadLine();
  16. if (String.IsNullOrEmpty(originalLine))
  17. {
  18. Console.WriteLine("Введенная последовательность пуста!");
  19. Console.ReadKey();
  20. return;
  21. }
  22. char[] vowels = new[] { 'а', 'е', 'и', 'о', 'у', 'я', 'ю' };
  23. string[] separate_line = originalLine.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
  24. string lastWord = separate_line[separate_line.Length - 1];
  25. for (int i = 0; i < separate_line.Length; i++ )
  26. {
  27. bool isAlternating = false;
  28. if (separate_line[i] != lastWord)
  29. {
  30. isAlternating = true;
  31. for (int j = 0; j < separate_line[i].Length - 1; j++)
  32. {
  33. if (vowels.Contains(separate_line[i][j]) && vowels.Contains(separate_line[i][j+1]))
  34. isAlternating = false;
  35. }
  36. }
  37.  
  38. if (isAlternating)
  39. Console.WriteLine(separate_line[i]);
  40. }
  41.  
  42. Console.WriteLine(lastWord);
  43. Console.WriteLine("Press <Enter> to exit.");
  44. Console.ReadLine();
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement