首页 > 中学考试杂题 > 题目详情
一、 程序填空1. 输入一串数字字符,当其个数为10时,进行各个数字求和运算,否则重新输入.CLEARSET TALK
题目内容:
一、 程序填空
1. 输入一串数字字符,当其个数为10时,进行各个数字求和运算,否则重新输入.
CLEAR
SET TALK OFF
S=0
DO WHILE .T.
ACCEPT “输入一串数字字符:” TO X
M= (1)
IF M=10
(2)
ENDIF
(3)
ENDDO
FOR N=1 TO 10
S=S+ (4)
ENDFOR
”该数字字符各个数字之和为:”,S
SET TALK ON
RETURN
2. 定义一个包含10个元素的A数组,该数组中已有9个数据且按从小到大顺序存放,第10个元素为空,现输入一个数放到数组中,且要求仍为由小到大顺序.
CLEAR
SET TALK OFF
DIME A(10)
FOR K=1 TO 9
INPUT "输入"+ "第"+STR(K,2)+ "个数据" TO A(K)
NEXT
INPUT “输入要插入的数:” TO X
FOR N=1 TO 9
IF A(N)>X
(5)
ENDIF
ENDFOR
FOR M=10 TO N+1 (6)
(7)
NEXT
(8)
FOR K=1 TO 10
A(K)
ENDFOR
SET TALK ON
RETURN
一、 程序填空
1. 输入一串数字字符,当其个数为10时,进行各个数字求和运算,否则重新输入.
CLEAR
SET TALK OFF
S=0
DO WHILE .T.
ACCEPT “输入一串数字字符:” TO X
M= (1)
IF M=10
(2)
ENDIF
(3)
ENDDO
FOR N=1 TO 10
S=S+ (4)
ENDFOR
”该数字字符各个数字之和为:”,S
SET TALK ON
RETURN
2. 定义一个包含10个元素的A数组,该数组中已有9个数据且按从小到大顺序存放,第10个元素为空,现输入一个数放到数组中,且要求仍为由小到大顺序.
CLEAR
SET TALK OFF
DIME A(10)
FOR K=1 TO 9
INPUT "输入"+ "第"+STR(K,2)+ "个数据" TO A(K)
NEXT
INPUT “输入要插入的数:” TO X
FOR N=1 TO 9
IF A(N)>X
(5)
ENDIF
ENDFOR
FOR M=10 TO N+1 (6)
(7)
NEXT
(8)
FOR K=1 TO 10
A(K)
ENDFOR
SET TALK ON
RETURN
1. 输入一串数字字符,当其个数为10时,进行各个数字求和运算,否则重新输入.
CLEAR
SET TALK OFF
S=0
DO WHILE .T.
ACCEPT “输入一串数字字符:” TO X
M= (1)
IF M=10
(2)
ENDIF
(3)
ENDDO
FOR N=1 TO 10
S=S+ (4)
ENDFOR
”该数字字符各个数字之和为:”,S
SET TALK ON
RETURN
2. 定义一个包含10个元素的A数组,该数组中已有9个数据且按从小到大顺序存放,第10个元素为空,现输入一个数放到数组中,且要求仍为由小到大顺序.
CLEAR
SET TALK OFF
DIME A(10)
FOR K=1 TO 9
INPUT "输入"+ "第"+STR(K,2)+ "个数据" TO A(K)
NEXT
INPUT “输入要插入的数:” TO X
FOR N=1 TO 9
IF A(N)>X
(5)
ENDIF
ENDFOR
FOR M=10 TO N+1 (6)
(7)
NEXT
(8)
FOR K=1 TO 10
A(K)
ENDFOR
SET TALK ON
RETURN
本题链接: