Advertisement
Guest User

Untitled

a guest
Nov 21st, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.97 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. using System. IO;
  7. namespace biblioteka
  8. {
  9. public class Operacje
  10. {
  11. public static void Zapisz(int liczba, string path)
  12. {
  13. StreamWriter sw = new StreamWriter(path);
  14. sw.Write(liczba);
  15. sw.Close();
  16. }
  17.  
  18. public static int OdczytajLiczbę(string path)
  19. {
  20. StreamReader sr = new StreamReader(path);
  21. int zPliku = Convert.ToUInt16(sr.ReadToEnd());
  22. sr.Close();
  23. return zPliku;
  24. }
  25. /* public static string[] ZnajdzPalindromy(string path)//funkcja ostateczne
  26. {
  27. StreamReader sr = new StreamReader(path);
  28.  
  29.  
  30. } */
  31.  
  32. public static bool CzyPalidrom(string wyraz)
  33. {
  34. for (int i = 0; i < (wyraz.Length) / 2; i++)
  35. {
  36. if (wyraz[i] != wyraz[(wyraz.Length - 1) - i])
  37. {
  38. return false;
  39. }
  40. }
  41. return true;
  42. }
  43. public static string Zamien(string wyraz)
  44. {
  45. for (int i = 0; i < wyraz.Length; i++)
  46. {
  47. char txt = wyraz[i];
  48. if (txt >= 'A' && txt <= 'Z')
  49. {
  50. txt = Convert.ToChar(txt + ('a' - 'A')); //dodajemy roznice pomiedzy indeksami malych liter a duzych
  51. }
  52.  
  53. }
  54. return wyraz;
  55. }
  56. public static bool CzyLiterka(char znak)
  57. {
  58. if (znak >= 'A' && znak <= 'Z' || znak >= 'a' && znak <= 'z')
  59. {
  60. return true;
  61. }
  62. return false;
  63. }
  64. public static int IleWyrazow(string tekst)
  65. {
  66. int suma = 1; //bo pierwszy wyraz ma inny schemat literka jako pierwsza
  67. for (int i = 0; i < tekst.Length; i++)
  68. {
  69. if (CzyLiterka(tekst[i + 1]) == true && CzyLiterka(tekst[i -1]) == false) /// łogarnąć ,k
  70. { suma = suma + 1; }
  71.  
  72. }
  73. return suma;
  74. }
  75.  
  76.  
  77. public static string[] ZwrocTabliceWyrazow(string tekst1) ////czy to wgl ma sens..
  78. {
  79. string[] TabWyrazow = new string[IleWyrazow(tekst1)];
  80. for (int i = 0; i < TabWyrazow.Length; i++)
  81. {
  82. for (int z = 0; i < tekst1.Length; z++)
  83. {
  84. while (CzyLiterka(tekst1[z]) == true)
  85. {
  86. TabWyrazow[i] = TabWyrazow[i] + tekst1[z];
  87. }
  88. }
  89. }
  90.  
  91. return TabWyrazow;
  92. }
  93.  
  94. public static string ZwrocPalidromy(string[] wyraz)
  95. {
  96. return null;
  97. }
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement