2012甘肃专升本计算机程序设计
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
2012甘肃专升本计算机程序设计
1、求解AX+BX+C=0的根、其中A、B、C三个参数由键盘输入。一元二次方程的求根公式是:X=-b±√b²-4ac/2a
clear
text
一元二次方程求解
ax^2+bx+c=0
endtext
input "请输入a的值:" to a
input "请输入b的值:" to b
input "请输入c的值:" to c
m=b*b-4*a*c
if m>=0
x1=(-b+sqrt(m))/(2*a)
x2=(-b-sqrt(m))/(2*a)
?"x1的值是:",x1
?"x2的值是:",x2
else
?"此方程无实根!"
endif
2、编写程序将1-100之间所有能被7和3整除的整数输出
clear
for i=1 to 100
if i%3=0 and i%7=0
??i
endif
endfor
3、编写程序计算e,e的近似值计算公式为:e=1+1/1!+1/2!+1/3!+...+1/n!,直到1/n!<0.000001为止
clear
e=1
n=1
do while .t.
k=1
for i=1 to n
k=k*i
endfor
m=1/k
e=e+m
if m<0.000001
exit
endif
n=n+1
enddo
?"e=1+1/1!+1/2!+1/3!+…+1/n!=",e
4、编写程序,计算1!+2!+3!+.......N!=?
clear
input "请输入n的值:" to n
s=0
t=1
for i=1 to n
t=t*i
s=s+t
endfor
?"1!+2!+3!+.......N!=",s
5、从键盘输入十个数,将它们进行降序排列。
clear
dime a(10)
for i=1 to 10
input "请输入一个数:" to a(i)
endfor
?"降序排列为:"
for i=1 to 9
for j=i+1 to 10