Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System. IO;
- namespace biblioteka
- {
- public class Operacje
- {
- public static void Zapisz(int liczba, string path)
- {
- StreamWriter sw = new StreamWriter(path);
- sw.Write(liczba);
- sw.Close();
- }
- public static int OdczytajLiczbę(string path)
- {
- StreamReader sr = new StreamReader(path);
- int zPliku = Convert.ToUInt16(sr.ReadToEnd());
- sr.Close();
- return zPliku;
- }
- /* public static string[] ZnajdzPalindromy(string path)//funkcja ostateczne
- {
- StreamReader sr = new StreamReader(path);
- } */
- public static bool CzyPalidrom(string wyraz)
- {
- for (int i = 0; i < (wyraz.Length) / 2; i++)
- {
- if (wyraz[i] != wyraz[(wyraz.Length - 1) - i])
- {
- return false;
- }
- }
- return true;
- }
- public static string Zamien(string wyraz)
- {
- for (int i = 0; i < wyraz.Length; i++)
- {
- char txt = wyraz[i];
- if (txt >= 'A' && txt <= 'Z')
- {
- txt = Convert.ToChar(txt + ('a' - 'A')); //dodajemy roznice pomiedzy indeksami malych liter a duzych
- }
- }
- return wyraz;
- }
- public static bool CzyLiterka(char znak)
- {
- if (znak >= 'A' && znak <= 'Z' || znak >= 'a' && znak <= 'z')
- {
- return true;
- }
- return false;
- }
- public static int IleWyrazow(string tekst)
- {
- int suma = 1; //bo pierwszy wyraz ma inny schemat literka jako pierwsza
- for (int i = 0; i < tekst.Length; i++)
- {
- if (CzyLiterka(tekst[i + 1]) == true && CzyLiterka(tekst[i -1]) == false) /// łogarnąć ,k
- { suma = suma + 1; }
- }
- return suma;
- }
- public static string[] ZwrocTabliceWyrazow(string tekst1) ////czy to wgl ma sens..
- {
- string[] TabWyrazow = new string[IleWyrazow(tekst1)];
- for (int i = 0; i < TabWyrazow.Length; i++)
- {
- for (int z = 0; i < tekst1.Length; z++)
- {
- while (CzyLiterka(tekst1[z]) == true)
- {
- TabWyrazow[i] = TabWyrazow[i] + tekst1[z];
- }
- }
- }
- return TabWyrazow;
- }
- public static string ZwrocPalidromy(string[] wyraz)
- {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement