数组问题
老师们:有两数组
========================================================================
Dim A,B,Count
Count=0
A=Array("2","4","9","10","11","16","37","38","39","49")
B=Array("3","8","9","11","15","36","37","38","39","40")
FOR i=0 to 9
FOR J=0 to 9
IF A(i) - B(j) = 1 OR A(i) - B(j)= -1 THEN
Count=Count + 1
END IF
NEXT
NEXT
=======================================================================
//以上代码实现的是:
统计数组B中的数是数组A中的相邻数的个数
例如:
数组B中的"3"是数组A中"4"的相邻数;数组B中的"38"是数组A中"39"的相邻数等等等等......
但是,以上代码会碰到以下问题,例如:
数组B中的"38",既是数组A中"39"的相邻数,同时也是数组A中"37"的相邻数,程序会把数组B中的"38"统计为2次;
可是我想实现的是,当碰到如数组B中"38"这样的数时,只统计1次即可,怎么修改代码??感谢老师!!