NCCU98_LAND 板


LINE

交换排序 Private Sub Form_Load() Randomize Dim aa(6) As Integer '宣告阵列为一维阵列,可内含7笔资料 Dim a As Integer For i = 1 To 5 '输入资料 aa(i) = Int(Rnd * 100) + 1 Next i For m = 1 To 4 '前次上课所教的排序法 For n = m + 1 To 5 If aa(m) > aa(n) Then a = aa(m): aa(m) = aa(n): aa(n) = a Next n Next m Text1.Text = aa(1) '输出 Text2.Text = aa(2) Text3.Text = aa(3) Text4.Text = aa(4) Text5.Text = aa(5) End Sub 泡沫排序 Private Sub Form_Load() Randomize Dim aa(6) As Integer Dim a As Integer For i = 1 To 5 '为输入资料到阵列中 aa(i) = Int(Rnd * 100) + 1 Next i For m = 1 To 4 '为前後交换之泡沫排序 flag = 0 'flag作为旗帜,一旦等於0就直接跳出 For n = 4 To m Step -1 If aa(n) > aa(n + 1) Then a = aa(m): aa(m) = aa(n): aa(n) = a flag = 1 Next n If flag = 0 Then Exit For Next m Text1.Text = aa(1) Text2.Text = aa(2) Text3.Text = aa(3) Text4.Text = aa(4) Text5.Text = aa(5) End Sub 猜数字(几A几B) Private Sub Command1_Click() Cls Dim a, b, c, m, n, a1, b1, c1 As Integer Randomize Do '由电脑乱数形成三个不同数字 a = Int(Rnd * 9 + 1) b = Int(Rnd * 9 + 1) c = Int(Rnd * 9 + 1) Loop Until a <> b And b <> c And a <> c Do '未达3A或六次,可继续执行 Do '由键盘输入,直至三数不同为止 p = "请输入三个1-9的不同数字" & vbCrLf & "你只有六次机会哦!" x = Int(InputBox(p, 猜数字)) a1 = Val(Mid(x, 1, 1)): b1 = Val(Mid(x, 2, 1)): c1 = Val(Mid(x, 3, 1)) '由输入的字串中撷取单一字串并数值化 If a1 = b1 Or b1 = c1 Or a1 = c1 Then MsgBox "请重新输入三个1-9的不同数字", 64, "猜数字" Else Exit Do End If Loop If a1 = a And b1 = b And c1 = c Then MsgBox "你好棒唷~~~一猜就对了!!", 64, "猜数字" End Else m = 0: n = 0 '每次的AB均由0起始 If a1 = a Then m = m + 1 ElseIf a1 = b Or a1 = c Then n = n + 1 End If If b1 = b Then m = m + 1 ElseIf b1 = a Or b1 = c Then n = n + 1 End If If c1 = c Then m = m + 1 ElseIf c1 = a Or c1 = b Then n = n + 1 End If MsgBox Val(m) & "A" & Val(n) & "B", 64, "猜数字" t = t + 1 End If Loop Until m = 3 Or t > 5 If m = 3 Then '将不同的结果输出不同讯息 MsgBox "不错喔!您只猜了" & Val(c) & "次" ElseIf t > 5 Then MsgBox "再来一次吧" End If End Sub Private Sub Command2_Click() End End Sub Private Sub Form_Load() Timer1.Enabled = True '启动计时器 Timer2.Enabled = True End Sub Private Sub Timer1_Timer() '将系统时间输出 Label5.Caption = Format(Time, "AM/PM hh:mm:ss") End Sub Private Sub Timer2_Timer() '藉由timer2倒数计时 'timer2的interval须设为15000,让他每15秒作用一次,代替倒数计时 MsgBox "time out, once again" End Sub anyway.... 明天考完若大家有空到计中一起讨论讨论.... 没收到我寄的信的人 把这篇的程式码给copy下来吧..... -- 胡思乱想又过了一夜 思念的疑问并没有解决 我又胡乱想过了一夜 情感的东西 是否需要感觉 也许我不知道 我是真不明了 人对情感的苛求 是否那麽重要 也许我不知道 你哪儿最好 让我情牵忘也忘不了 也许我不知道 你真的那麽好 我的思念你又明了多少 我胡思乱想







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Tech_Job站内搜寻

TOP