Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Collections.Generic;
- using System.Text.RegularExpressions;
- class MainClass
- {
- static int Minimum(int a, int b, int c)
- {
- int min = 0;
- if (a <= b && a <= c)
- min = a;
- else if (b <= a && b <= c)
- min = b;
- else if (c <= a && c <= b)
- min = c;
- return min;
- }
- public static string Replace_s(string str)
- {
- Regex regF = new Regex(@"[^a-z0-9\s]");
- str = regF.Replace(str.ToLower(), string.Empty);
- MatchCollection regS = Regex.Matches(str, @"[a-z0-9]{4,}\s?");
- str = "";
- foreach (Match match in regS)
- {
- str += match.Value;
- }
- return str;
- }
- public static void Jaccard(string firstString, string secondString)
- {
- double c = 0.0;
- double length = 0.0;
- double n = firstString.Length;
- double m = secondString.Length;
- if (n <= m)
- length = n;
- else length = m;
- for (int i = 0; i < length; i++)
- if (firstString[i] == secondString[i])
- c++;
- //Console.WriteLine("{0} {1} {2}", n, m, c);
- double result = c/(n+m-c);
- Console.Write(Math.Round(result, 8));
- }
- public static void Main(string[] args)
- {
- string firstString;
- string secondString;
- firstString = Console.ReadLine();
- secondString = Console.ReadLine();
- firstString = Replace_s(firstString);
- secondString = Replace_s(secondString);
- Jaccard(firstString, secondString);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement