Re: 請高手幫小弟一個忙
Option Explicit
Private Sub CmdRun_Click()
Dim iIndexX As Integer
Dim iIndexY As Integer
Dim iIndexZ As Integer
Dim iIndexK As Currency
Dim iSum As Currency
Dim iCount As Integer
Dim sStr As String
For iIndexX = 0 To 5
For iIndexY = 0 To 6
For iIndexZ = 0 To 12
For iIndexK = 0 To 13
iSum = iIndexX * 267 + iIndexY * 215 + iIndexZ * 110 + iIndexK * 102.5
If iSum >= 1233 And iSum <= 1355 Then
sStr = sStr & iIndexX & " " & iIndexY & " " & iIndexZ & " " & iIndexK & " " & iSum & vbCrLf
iCount = iCount + 1
End If
Next
Next
Next
Next
Call VB.Clipboard.Clear
Call VB.Clipboard.SetText(sStr)
MsgBox iCount
End Sub
Private Sub CmdRun_Click()
Dim iIndexX As Integer
Dim iIndexY As Integer
Dim iIndexZ As Integer
Dim iIndexK As Currency
Dim iSum As Currency
Dim iCount As Integer
Dim sStr As String
For iIndexX = 0 To 1355 Step 267
For iIndexY = 0 To 1355 Step 215
For iIndexZ = 0 To 1355 Step 110
For iIndexK = 0 To 1355 Step 102.5
iSum = iIndexX + iIndexY + iIndexZ + iIndexK
If iSum >= 1233 And iSum <= 1355 Then
sStr = sStr & (iIndexX / 267) & " " & (iIndexY / 215) & " " & (iIndexZ / 110) & " " & (iIndexK / 102.5) & " " & iSum & vbCrLf
iCount = iCount + 1
End If
Next
Next
Next
Next
Call VB.Clipboard.Clear
Call VB.Clipboard.SetText(sStr)
MsgBox iCount
End Sub
0 0 0 13 1332.5
0 0 1 11 1237.5
0 0 1 12 1340
0 0 2 10 1245
0 0 2 11 1347.5
0 0 3 9 1252.5
0 0 3 10 1355
0 0 4 8 1260
0 0 5 7 1267.5
0 0 6 6 1275
0 0 7 5 1282.5
0 0 8 4 1290
0 0 9 3 1297.5
0 0 10 2 1305
0 0 11 1 1312.5
0 0 12 0 1320
0 1 0 10 1240
0 1 0 11 1342.5
0 1 1 9 1247.5
0 1 1 10 1350
0 1 2 8 1255
0 1 3 7 1262.5
0 1 4 6 1270
0 1 5 5 1277.5
0 1 6 4 1285
0 1 7 3 1292.5
0 1 8 2 1300
0 1 9 1 1307.5
0 1 10 0 1315
0 2 0 8 1250
0 2 0 9 1352.5
0 2 1 7 1257.5
0 2 2 6 1265
0 2 3 5 1272.5
0 2 4 4 1280
0 2 5 3 1287.5
0 2 6 2 1295
0 2 7 1 1302.5
0 2 8 0 1310
0 3 0 6 1260
0 3 1 5 1267.5
0 3 2 4 1275
0 3 3 3 1282.5
0 3 4 2 1290
0 3 5 1 1297.5
0 3 6 0 1305
0 4 0 4 1270
0 4 1 3 1277.5
0 4 2 2 1285
0 4 3 1 1292.5
0 4 4 0 1300
0 5 0 2 1280
0 5 1 1 1287.5
0 5 2 0 1295
0 6 0 0 1290
1 0 0 10 1292
1 0 1 9 1299.5
1 0 2 8 1307
1 0 3 7 1314.5
1 0 4 6 1322
1 0 5 5 1329.5
1 0 6 3 1234.5
1 0 6 4 1337
1 0 7 2 1242
1 0 7 3 1344.5
1 0 8 1 1249.5
1 0 8 2 1352
1 0 9 0 1257
1 1 0 8 1302
1 1 1 7 1309.5
1 1 2 6 1317
1 1 3 5 1324.5
1 1 4 4 1332
1 1 5 2 1237
1 1 5 3 1339.5
1 1 6 1 1244.5
1 1 6 2 1347
1 1 7 0 1252
1 1 7 1 1354.5
1 2 0 6 1312
1 2 1 5 1319.5
1 2 2 4 1327
1 2 3 3 1334.5
1 2 4 1 1239.5
1 2 4 2 1342
1 2 5 0 1247
1 2 5 1 1349.5
1 3 0 4 1322
1 3 1 3 1329.5
1 3 2 1 1234.5
1 3 2 2 1337
1 3 3 0 1242
1 3 3 1 1344.5
1 3 4 0 1352
1 4 0 2 1332
1 4 1 0 1237
1 4 1 1 1339.5
1 4 2 0 1347
1 5 0 0 1342
2 0 0 7 1251.5
2 0 0 8 1354
2 0 1 6 1259
2 0 2 5 1266.5
2 0 3 4 1274
2 0 4 3 1281.5
2 0 5 2 1289
2 0 6 1 1296.5
2 0 7 0 1304
2 1 0 5 1261.5
2 1 1 4 1269
2 1 2 3 1276.5
2 1 3 2 1284
2 1 4 1 1291.5
2 1 5 0 1299
2 2 0 3 1271.5
2 2 1 2 1279
2 2 2 1 1286.5
2 2 3 0 1294
2 3 0 1 1281.5
2 3 1 0 1289
3 0 0 5 1313.5
3 0 1 4 1321
3 0 2 3 1328.5
3 0 3 1 1233.5
3 0 3 2 1336
3 0 4 0 1241
3 0 4 1 1343.5
3 0 5 0 1351
3 1 0 3 1323.5
3 1 1 2 1331
3 1 2 0 1236
3 1 2 1 1338.5
3 1 3 0 1346
3 2 0 1 1333.5
3 2 1 0 1341
4 0 0 2 1273
4 0 1 1 1280.5
4 0 2 0 1288
4 1 0 0 1283
5 0 0 0 1335
※ 引述《apexmilo (失意人)》之銘言:
: 我有一個數學問題
: 267*X+215*Y+110*Z+102.5*K=1233~1355間
: 我想知道有幾種組合
: 請問板上高手 有辦法寫出來嗎?
: 請高手大大忙小弟!
--
常發人好人名片
Yaiba:您好,我是好人
幫正妹組電腦送到府
外加一年到府維護
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 220.135.14.200
※ 文章網址: https://www.ptt.cc/bbs/Visual_Basic/M.1478282436.A.112.html
→
11/05 02:01, , 1F
11/05 02:01, 1F
→
11/05 02:02, , 2F
11/05 02:02, 2F
→
11/05 02:03, , 3F
11/05 02:03, 3F
→
11/05 02:03, , 4F
11/05 02:03, 4F
→
11/05 02:04, , 5F
11/05 02:04, 5F
→
11/05 14:46, , 6F
11/05 14:46, 6F
但認真來說 五分鐘就可以從0寫到100的程式
我真的也不感覺有什麼差
如果是還有使用我以前寫的程式來節省時間的話那當然不一樣
但這程式是打開VB6 用手打不到五分鐘
寫四個迴圈 一個IF就完成的
這跟玩解迷遊戲 用爆力去Try
我感覺是差不多的
如果要花到半小時 或一小時
而且有其邏輯要思考的地方
那當然也不一樣
這題目真的沒難度啦...
※ 編輯: Yaiba (220.135.14.200), 11/05/2016 22:30:00
推
01/04 00:11, , 7F
01/04 00:11, 7F
討論串 (同標題文章)
Visual_Basic 近期熱門文章
PTT數位生活區 即時熱門文章