小弟是初学者,谁能帮我把这两道题做出来啊!急啊!!!

jazbor 2002-12-30 11:35:25
1。打印下面的图形
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321


2.任意输入3个字母,由程序判断其中是否包括字母表的相邻字母
例如:输入:gfn,因为gf相邻,所以输入YES

以上两题是我考试所以划出的重点,我实在是有心无力,忘大侠们帮帮忙,真得急!!
...全文
12 点赞 收藏 6
写回复
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
northwolves 2003-03-30
Private Sub Command1_Click()
MsgBox isneighber("acs") & vbCrLf & isneighber("buc")
End Sub

Function isneighber(ByVal x As String) As Boolean
If Len(x) >= 4 Or Len(x) < 3 Then Exit Function
isneighber = False
If Abs(Asc(Mid(x, 1, 1)) - Asc(Mid(x, 2, 1))) = 1 Or Abs(Asc(Mid(x, 2, 1)) - Asc(Mid(x, 3, 1))) = 1 Or Abs(Asc(Mid(x, 1, 1)) - Asc(Mid(x, 3, 1))) = 1 Then isneighber = True
End Function
回复
hycghit 2003-03-29
这个程序和杨辉三角、九九表有异曲同工之妙!
我就给出一个九九表的程序:

Private Sub Command1_Click()
Dim int1 As Integer, int2 As Integer
CurrentX = 0: CurrentY = 100 ' 使第一行离标题栏100单位
For int1 = 1 To 9 ' 每次循环生成一行
For int2 = 1 To int1 ' 每次循环生成一项
Print Spc(3); CStr(int2); "×"; CStr(int1); "="; CStr(int1 * int2);
Next
Print ' 另起一行
Print ' 两行之间隔一空行
Next
End Sub
回复
jazbor 2003-03-29
3Q
回复
huangyun 2002-12-30
Private Sub Command1_Click()
If Len(Text1.Text) >= 4 Then MsgBox "输入数据必须等于三个字母", , "错误提示"
If Asc(Mid(Text1.Text, 1, 1)) + 1 = Asc(Mid(Text1.Text, 2, 1)) Or Asc(Mid(Text1.Text, 2, 1)) + 1 = Asc(Mid(Text1.Text, 3, 1)) Then MsgBox "Yes", , "Titile"
End Sub
回复
huangyun 2002-12-30
Private Sub Command1_Click()
For i = 1 To 9
mystr = 1
For j = 2 To i
mystr = mystr & j
Next j
For k = i - 1 To 1 Step -1
mystr = mystr & k
Next k
mystr = CDec(mystr)
Print Spc(9 - i); mystr
Next i
End Sub
回复
Juchiyufei 2002-12-30
for i%=1 to 9
print tab(10-i%);
for j%=1 to i%
print j%;
next
print
next
回复
发动态
发帖子
VB基础类
创建于2007-09-28

7452

社区成员

VB 基础类
申请成为版主
社区公告
暂无公告