回复 6# 1139054012
这个可以帮助找到关键词- #@&cls&powershell -sta "gc '%~f0'|out-string|iex"&pause&exit
- $files = Get-ChildItem -Recurse -File
- Add-Type @"
- using System;
- namespace CS
- {
- public static class LCS
- {
- public static string lcs(string a, string b)
- {
- var lengths = new int[a.Length, b.Length];
- int greatestLength = 0;
- string output = "";
- for (int i = 0; i < a.Length; i++)
- {
- for (int j = 0; j < b.Length; j++)
- {
- if (a[i] == b[j])
- {
- lengths[i, j] = i == 0 || j == 0 ? 1 : lengths[i - 1, j - 1] + 1;
- if (lengths[i, j] > greatestLength)
- {
- greatestLength = lengths[i, j];
- output = a.Substring(i - greatestLength + 1, greatestLength);
- }
- }
- else
- {
- lengths[i, j] = 0;
- }
- }
- }
- return output;
- }
- }
- }
- "@
-
- $lcsList = @()
- for ($i = 0; $i -lt $files.Count; $i++) {
- for ($j = $i + 1; $j -lt $files.Count; $j++) {
- $lcs = [CS.LCS]::lcs($files[$i].BaseName,$files[$j].BaseName)
- if ($lcsList -notcontains $lcs) {
- $lcsList += $lcs
- Write-Output "$lcs"
- }
- }
- }
复制代码
|