fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static bool samogloski(char a)
  6. {
  7.  
  8.  
  9. if (a == 'a' || a == 'e' || a == 'o' || a == 'u' || a == 'y' || a == 'i' || a == 'A' || a == 'E' || a == 'O' || a == 'U' || a == 'Y' || a == 'I')
  10. {
  11. return true;
  12. }
  13.  
  14. return false; ;
  15. }
  16. public static bool litera(char a)
  17. {
  18. if (('a' <= a && (int)a <= 'z') || ('A' <= (int)a && (int)a <= 'Z'))
  19. {
  20. return true;
  21. }
  22. return false;
  23. }
  24.  
  25. public static string zdanie1(string b)
  26. {
  27. int sa = 0, sp = 0, s = 0, d = 0;
  28. int p = 0, k = 0,l=0,o=0;
  29. string a = b + '.', c = "";
  30. while(litera(a[o])==true){
  31. l++;
  32. o++;
  33. }
  34. for(int i=0;i<o;i++){
  35. if (samogloski(b[i])==true){
  36. sa++;
  37. }
  38. }
  39.  
  40. if(sa<(o-sa)){
  41. for(int i=0;i<o;i++){
  42. c+=a[i];
  43. }
  44. c+=" ";
  45. }
  46.  
  47. sa=0;
  48.  
  49. for (int i = l; i < a.Length; i++)
  50. {
  51.  
  52. if (litera(a[i]) == true)
  53. {
  54. if (litera(a[i-1]) ==false && litera(a[i]) == true)
  55. {
  56. p = i;
  57. }
  58.  
  59. if (litera(a[i]) == true && litera(a[i + 1]) == false)
  60. {
  61. k = i;
  62. }
  63.  
  64. d++;
  65. if (samogloski(b[i]) == true)
  66. {
  67. sa++;
  68. }
  69. else
  70. {
  71. sp++;
  72. }
  73. }
  74. else
  75. {
  76. if (d > 0)
  77. {
  78. if (sa < sp)
  79. {
  80. for (int j = p; j <= k; j++)
  81. {
  82. c += a[j];
  83. }
  84. c += " ";
  85. }
  86. }
  87. p = 0;
  88. k = 0;
  89. sa = 0;
  90. sp = 0;
  91. d = 0; ;
  92. }
  93. }
  94. return c;
  95. }
  96. public static void Main()
  97. {
  98. Console.WriteLine(zdanie1("Ala, amma kota i psa"));
  99. }
  100. }
Success #stdin #stdout 0.02s 24292KB
stdin
Standard input is empty
stdout
psa