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 CodEx;
- public class osek
- {
- public static string VyradPismena(string s, string t)
- {
- StringBuilder u = new StringBuilder(t);
- bool pravda = false;
- for (int i = 0; i < u.Length; i++)
- {
- for (int j = 0; j < s.Length; j++)
- {
- if (u[i] == s[j])
- {
- pravda = true;
- break;
- }
- }
- if (pravda == false)
- {
- u.Remove(i, 1);
- i--;
- }
- pravda = false;
- }
- return u.ToString();
- }
- }
- public class hledani
- {
- public static void rekurze(int i)
- {
- for (int j = program.x; j <= program.t.Length - 1; j = j + 1)
- {
- if (program.s[i] == program.t[j] && i < program.s.Length - 1 && j <= (program.t.Length - program.s.Length + i))
- {
- program.x = j + 1;
- rekurze(i + 1);
- }
- if (program.s[i] == program.t[j] && i == program.s.Length - 1)
- {
- program.pocet = program.pocet + 1;
- }
- }
- }
- }
- class program
- {
- public static string s = "";
- public static string t = "";
- public static int pocet = 0;
- public static int x = 0;
- static void Main(string[] args)
- {
- int i = 0;
- s = Console.ReadLine();
- int c = 0;
- string row;
- /*while ((row = Reader.Console().Line()) != null)
- {
- t += row;
- }
- while ((c = Console.Read()) != -1)
- {
- t += (char)c;
- }*/
- t = Console.ReadLine();
- DateTime ExecutionStartTime = DateTime.Now;
- osek.VyradPismena(s, t);
- DateTime ExecutionStopTime = DateTime.Now;
- TimeSpan rozdil = ExecutionStopTime - ExecutionStartTime;
- Console.WriteLine(rozdil.Seconds);
- ExecutionStartTime = DateTime.Now;
- hledani.rekurze(i);
- ExecutionStopTime = DateTime.Now;
- rozdil = ExecutionStopTime - ExecutionStartTime;
- Console.WriteLine(rozdil.Seconds);
- Console.WriteLine(pocet);
- Console.ReadLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement