关于VB的几道题目.给代码我就好了.

[复制链接]
查看11 | 回复0 | 2009-6-21 17:43:29 | 显示全部楼层 |阅读模式
第1题:Private Function su(ByVal n As Integer) As BooleanDim i As IntegerFor i = 2 To Sqr(n)If n Mod i = 0 Thensu = FalseExit FunctionEnd IfNext isu = TrueEnd FunctionPrivate Sub command1_click() '按钮的单击事件Dim i As Integer, s As Integer, n As IntegerDo
n = i * i + i + 41
s = s + n
i = i + 1Loop While su(n)Print "这个数是"; iPrint "和为"; sEnd Sub第2题 数字三角:Dim N As Integer, i As Integer, j As Integer, s As IntegerN = InputBox("请输入一个数:(1到32767)")i = 1j = 1Do While s < Ns = i * (i + 1) / 2i = i + 1Loopi = i - 1s = i * (i - 1) / 2j = N - sPrint N; i; j
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行