随机双色球,6个红球,范围在1到33,取随机数。1个篮球,范围在1到16,取一个随机数。会验证同一组中红球随机数不会重复。 | $count = @() | | $item = @() | | $max = 33 | | $min = 1 | | | | | | Write-Verbose "Creating Excel application" | | $xl=New-Object -ComObject "Excel.Application" | | $wb=$xl.Workbooks.Add() | | $ws=$wb.Worksheets.Add() | | $cells=$ws.Cells | | | | | | $row=3 | | $col=1 | | | | "Red1","Red2","Red3","Red4","Red5","Red6",“Blue” | foreach { | | $cells.item($row,$col)=$_ | | $cells.item($row,$col).font.bold=$True | | $col++ | | } | | | | | | for($j=1;$j -le 5;$j++) | | { | | $row++ | | $col=1 | | for($i=1; $i -le 6; $i++) | | { | | $b = Get-Random -Minimum $min -Maximum $max | | $bl=$count.Contains($b) | | while($bl){ | | $b = Get-Random -Minimum $min -Maximum $max | | $bl=$count.Contains($b) | | } | | $count += $b | | | | $cells.item($Row,$col) = $b | | $col++ | | } | | | | $cells.item($Row,$col) = Get-Random -Minimum 1 -Maximum 16 | | | | | | } | | | | | | | | $xl.Visible=$True | | $xl.Quit()COPY |
|