【发布时间】:2020-12-08 20:04:02
【问题描述】:
我有一个如下所示的整数数组,我想在 powershell 中计算该数组中 1 的数量,有人可以帮我吗?
[array]$inputs = 81,11,101,1811,1981
$count = 0
foreach($input in $inputs)
{
Write-Host "Processing element $input"
$count += ($input -like "*1*" | Measure-Object).Count
}
Write-Host "Number of 1's in the given array is $count"
它在该数组中只给了我 5 个 1,但预期的答案是 10。任何帮助将不胜感激
【问题讨论】:
标签: arrays powershell integer