Advertisement
Danielos168

Untitled

Apr 7th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 KB | None | 0 0
  1. namespace ConsoleApp14
  2. {
  3.     static class SuperString
  4.     {
  5.         public static string Odwroc(this string input)
  6.         {
  7.             char[] temp;
  8.             temp = input.ToCharArray();
  9.             Array.Reverse(temp);
  10.             return new string(temp);
  11.         }
  12.  
  13.         public static string Ile(this string input, char a)
  14.         {
  15.             int counter=0;
  16.             foreach (char b in input)
  17.             {
  18.                 if (b == a)
  19.                 {
  20.                     counter++;
  21.                 }
  22.             }
  23.             return $"W podanym tekscie znajduje się {counter} szukanych znaków. ";
  24.         }
  25.  
  26.         public static string Skroc(this string input, int n)
  27.         {
  28.             string temp = "";
  29.             for (int i = 0; i < n-(n/2); i++)
  30.             {
  31.                 temp += input[i];
  32.             }
  33.  
  34.             for (int i = input.Length-(n/2); i <input.Length ; i++)
  35.             {
  36.                 temp += input[i];
  37.             }
  38.  
  39.             return temp;
  40.         }
  41.  
  42.         public static string Usun(this string input, string t)
  43.         {
  44.            string temp= input.Replace(t, "");
  45.             return temp;
  46.         }
  47.     }
  48.     class Program
  49.     {
  50.         static void Main(string[] args)
  51.         {
  52.             string s = "onyTelefony";
  53.             Console.WriteLine(s.Odwroc());
  54.             Console.WriteLine(s.Ile('e'));
  55.             Console.WriteLine(s.Skroc(4));
  56.             Console.WriteLine(s.Usun("ony"));
  57.             Console.ReadKey();
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement