VFP编程题
定义一个二维数组X(8,9)给数组元素赋值为该元素下标组成的数值.即X(1,1)赋值为11,给X(1,2)赋值为12,如此类推...
定义一个二维数组X(8,9)给数组元素赋值为该元素下标组成的数值.即X(1,1)赋值为11,给X(1,2)赋值为12,如此类推
展开
展开全部
CLEAR ALL
CLOSE ALL
CLEAR
*** 以下是二维数组中的值为字符型的:
DIMENSION X(8, 9)
FOR nLoop_01 = 1 TO 8
FOR nLoop_02 = 1 TO 9
X(nLoop_01, nLoop_02) = ALLTRIM(STR(nLoop_01)) + ALLTRIM(STR(nLoop_02))
NEXT
NEXT
FOR nLoop_01 = 1 TO 8
?SPACE(05)
FOR nLoop_02 = 1 TO 9
IF nLoop_02 = 9
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + X(nLoop_01, nLoop_02)
ELSE
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + X(nLoop_01, nLoop_02) + ", "
ENDIF
NEXT
NEXT
?
*** 以下是二维数组中的值为数字型的:
DIMENSION X(8, 9)
FOR nLoop_01 = 1 TO 8
FOR nLoop_02 = 1 TO 9
X(nLoop_01, nLoop_02) = VAL(ALLTRIM(STR(nLoop_01)) + ALLTRIM(STR(nLoop_02)))
NEXT
NEXT
FOR nLoop_01 = 1 TO 8
?SPACE(05)
FOR nLoop_02 = 1 TO 9
IF nLoop_02 = 9
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + ALLTRIM(STR(X(nLoop_01, nLoop_02),5, 2))
ELSE
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + ALLTRIM(STR(X(nLoop_01, nLoop_02),5, 2)) + ", "
ENDIF
NEXT
NEXT
RETURN
*** 在以下版本中测试通过:
*** FoxPro2.0, FoxPro2.6
*** VFP6.0, VFP7.0 & VFP9.0
CLOSE ALL
CLEAR
*** 以下是二维数组中的值为字符型的:
DIMENSION X(8, 9)
FOR nLoop_01 = 1 TO 8
FOR nLoop_02 = 1 TO 9
X(nLoop_01, nLoop_02) = ALLTRIM(STR(nLoop_01)) + ALLTRIM(STR(nLoop_02))
NEXT
NEXT
FOR nLoop_01 = 1 TO 8
?SPACE(05)
FOR nLoop_02 = 1 TO 9
IF nLoop_02 = 9
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + X(nLoop_01, nLoop_02)
ELSE
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + X(nLoop_01, nLoop_02) + ", "
ENDIF
NEXT
NEXT
?
*** 以下是二维数组中的值为数字型的:
DIMENSION X(8, 9)
FOR nLoop_01 = 1 TO 8
FOR nLoop_02 = 1 TO 9
X(nLoop_01, nLoop_02) = VAL(ALLTRIM(STR(nLoop_01)) + ALLTRIM(STR(nLoop_02)))
NEXT
NEXT
FOR nLoop_01 = 1 TO 8
?SPACE(05)
FOR nLoop_02 = 1 TO 9
IF nLoop_02 = 9
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + ALLTRIM(STR(X(nLoop_01, nLoop_02),5, 2))
ELSE
??"X(" + ALLTRIM(STR(nLoop_01)) + "," + ALLTRIM(STR(nLoop_02)) + ")=" + ALLTRIM(STR(X(nLoop_01, nLoop_02),5, 2)) + ", "
ENDIF
NEXT
NEXT
RETURN
*** 在以下版本中测试通过:
*** FoxPro2.0, FoxPro2.6
*** VFP6.0, VFP7.0 & VFP9.0
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询