Advertisement
Guest User

wtf

a guest
Dec 12th, 2018
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace k3._2
  8. {
  9. class Program
  10. {
  11.  
  12. static bool CzyLitera(char a)
  13. {
  14. if (a>='A'&&a<='Z'||a>='a'&&a<='z')
  15. {
  16. return true;
  17. }
  18. return false;
  19. }
  20. static string Zamienmale(string a)
  21. {
  22. string tmp = "";
  23. char c;
  24. for (int i = 0; i < a.Length; i++)
  25. {
  26. if (CzyLitera(a[i]))
  27. {
  28. if (a[i] >= 'a' && a[i] <= 'z')
  29. {
  30. tmp += a[i];
  31.  
  32. }
  33. if (a[i] >= 'A' && a[i] <= 'Z')
  34. {
  35. c = (char)(a[i] + ('a' - 'A'));
  36. tmp += c;
  37.  
  38. }
  39. }
  40. else
  41. {
  42. tmp += a[i];
  43. }
  44.  
  45.  
  46. }
  47. return tmp;
  48.  
  49.  
  50.  
  51. }
  52.  
  53. static int IleWyrazow(string tekst, char a, char b, char c)
  54. {
  55. string d = Zamienmale(tekst);
  56. string tmp = "";
  57. int liczbasekwencji = 0;
  58. int liczbawyrazow = 0;
  59. for (int i = 0; i < d.Length; i++)
  60. {
  61. if (CzyLitera(d[i])&&i<d.Length)
  62. {
  63. while (i < d.Length&&CzyLitera(d[i]))
  64. {
  65. tmp += d[i];
  66. i++;
  67. }
  68.  
  69. for (int j = 0; j < tmp.Length-2; j++)
  70. {
  71. if (tmp[j]=='a'&&tmp[j+1]!='b'&&tmp[j+2]=='c')
  72. {
  73. liczbasekwencji++;
  74. }
  75. }
  76. tmp = "";
  77. if (liczbasekwencji == 1)
  78. {
  79. liczbawyrazow++;
  80. }
  81.  
  82.  
  83. }
  84. }
  85. return liczbawyrazow;
  86.  
  87.  
  88. }
  89. static void Main(string[] args)
  90. {
  91.  
  92. string b = "katar";
  93.  
  94. Console.WriteLine(IleWyrazow(b,'a','l','a'));
  95. Console.ReadKey();
  96. }
  97. }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement