Re: [请问] 有没有类似九宫格乱码器or程式

楼主: tino926 (走啦!去喝酒)   2024-01-31 08:13:27
虽然原po已决定的方法,不过我刚好在试一个类chatgpt服务
以下是它给的做法:
这个方法在目前的windows下不用另外安装软件
1. 以管理员权限开启 windows PowerShell
https://www.google.com/search?q=windows+PowerShell+administrator
2. 执行以下指令:
Set-ExecutionPolicy RemoteSigned
3. 开新文字档贴上文末程式码,将档名改为 script.ps1
4. windows powershell 视窗切换到 script.ps1 所在目录
.\script.ps1 -InputFile "in.txt" -OutputFile "out.txt"
会随机重排 in.txt 中的文字,存入 out.txt
宽度会自动设为字数的平方根
若加上 -Width 7 ,out.txt 中每行宽度就会是 7
powershell 程式码:
param(
[Parameter(Mandatory=$true)]
[string]$InputFile,
[Parameter(Mandatory=$true)]
[string]$OutputFile,
[int]$Width=0
)
$text = Get-Content -Path $InputFile -Raw
$text = $text -replace '\s',''
$chars = $text.ToCharArray()
$random = New-Object System.Random
$chars = $chars | Sort-Object { $random.Next() }
$text = -join $chars
if ($Width -eq 0) {
$Width = [Math]::Sqrt($text.Length)
Write-Host "hihi here"
}
$lines = $text -split '(.{' + $Width + '})' | Where-Object { $_ }
$lines | Out-File -FilePath $OutputFile
※ 引述《aisidi (调配咖哩粉)》之铭言:
: 我想把两首诗词打乱
: 铺排成类似九宫格
: (九只是虚数,不一定是九,)
: 有没有程式or线上软件
: 可以直接帮忙铺排的
: 先谢大家的分享了^^

Links booklink

Contact Us: admin [ a t ] ucptt.com