Created
August 16, 2017 07:12
-
-
Save b4tman/e81f0f0811b5455f542f66d0b9674ea1 to your computer and use it in GitHub Desktop.
сумма по строкам
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
param( | |
[parameter(Mandatory=$true, Position=1)] | |
[string]$Text | |
) | |
function SReplace($str) | |
{ | |
[string]$ret = $str | |
[string[]] $Del = "`n,`r,`t, ,`",`",`',`'," -split "," | |
$Del += [char]([byte]160) | |
$Del | Foreach-Object -Process { $ret = $ret -replace $_, ""} | |
$ret = $ret -replace ",","." | |
return $ret | |
} | |
[string[]] $lines = $Text -split "`n" | |
[double] $sum = 0 | |
$lines | Foreach-Object -Process { | |
$sum += [double] (SReplace $_) | |
} | |
return $sum |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment