本帖最后由 yhcfsr 于 2019-3-7 20:28 编辑
- <# :
- @echo off&cd/d "%~dp0"
- more +8 "%~f0" >"%temp%\%~n0.ps1"
- powershell -NoLogo -NoProfile -ExecutionPolicy bypass -File "%temp%\%~n0.ps1"
- del /f /q "%temp%\%~n0.ps1"
- pause
- #>
-
- $file = 'C:\Users\CF\Desktop\1.txt';#文本路径
-
- $ErrorActionPreference = 'SilentlyContinue';
- $text = [io.file]::ReadAllText($file,[text.encoding]::Default);
- [System.Collections.ArrayList] $arr = ($text -split '\s');
- $result = @{};
-
- foreach($elem in $arr)
- {
- if($elem) {
- $elem = $elem -replace '6','1';
- $str='';
- $elem -split ''|sort-object|%{$str+=$_}
-
- $result.Add([int] $str, $str);
- if(!$?) { $result[[int] $str] += ' ' + $str; }
- }
- }
-
- $arr.Clear();
- foreach($key in $result.Keys|Sort-Object)
- {
- [void] $arr.Add($result[$key]);
- }
-
- [io.file]::WriteAllLines('结果.txt',$arr,[text.encoding]::Default);#输出结果
复制代码
|