|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
本帖最后由 一把小刀闯天下 于 2018-10-8 12:50 编辑
'掰一个,是否正确就不晓得了
Option Explicit
Const P = 2, Q = 3
Sub test()
Dim i, a, b, k, sum, cnt, arr(), t
If P < 1 Or Q < 1 Then MsgBox "!": Exit Sub
a = P: b = Q
If a > b Then k = a: a = b: b = k
If a = b Or b Mod a = 0 Then
If b Mod a = 0 Then
ReDim arr(1 To b)
For i = 1 To b: arr(i) = "1/" & b: Next
Else
If a = 1 Then
ReDim arr(1 To 1): arr(1) = "1/1"
Else
ReDim arr(1 To a)
For i = 1 To a: arr(i) = "1/" & a: Next
End If
End If
Else
ReDim Preserve arr(1 To a)
For i = 1 To a
cnt = cnt + 1: arr(cnt) = "1/" & b
Next
ReDim Preserve arr(1 To cnt + (b - a) * a)
For i = 1 To (b - a) * a
cnt = cnt + 1: arr(cnt) = "1/" & b * a
Next
End If
Debug.Print Join(arr, ",")
End Sub
|
|