- 26
- 0
- 约4.33千字
- 约 7页
- 2020-10-27 发布于江苏
- 举报
1、求解AX^2+BX+C=0的根、其中A、B、C三个参数由键盘输入。一元二次方程的求根公式是:X=-b±√b2-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 m0.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
if a(i)a(j)
k=a(i)
a(i)=a(j)
a(j)=k
endif
endfor
??alltrim(str(a(i)))+
endfor
??alltrim(str(a(i)))
6、(1)输出有*号组成的图形:
*
***
*****
*******
*****
***
*
clear
for i=-3 to 3
?space(abs(i))
for j=1 to 7-abs(i)*2
??*
endfor
endfor
(2)
*
***
*****
*******
*********
clear
for i=1 to 5
?space(5-i)
for j=1 to 2*i-1
??*
endfor
endfor
7、编写一个程序产生一个有20项的Fibonacci数列并输出。注:Fibonacci数列的前两项为1,从第三项开始每一项是其前两项只和。
clear
a=1
b=1
??a,b
for i=1 to 18
c=a+b
a=b
b=c
??c
endfor
8、九九乘法表
clear
for i=1 to 9
for j=1 to i
??alltrim(str(i))+*+alltrim(str(j))+=+alltrim(str(i*j))+space(3)
endfor
?
Endfor
9、显示1-100之间的所有素数,并求它们的和。
clear
s=0
??1到100之间的素数为:
for i=2 to 100
x=0
for j=2 to i-1
if i/j=int(i/j)
x=1
endif
endfor
if x=0
??alltrim(str(i))+
s=s+i
endif
endfor
?它们的和是:,s
10、求100到999之间的水仙花数。
clear
?100-999之间的水仙花数有:
for i=100 to 999
k=int(i/100)
m=(int(i/10))%10
n=i%10
if k^3+m^3+n^3=i
??alltrim(str(i))+space(2)
endif
endfor
11、从键盘输入10个数,找出其中的最大数和最小数。
clear
input 请输入第1个数: to a
k=a
for i=2 to 10
input 请输入第+alltrim(str(i))+个数: to b
if ab
a=b
endif
if kb
您可能关注的文档
最近下载
- DB31T 1104-2018 城市轨道交通导向标识系统设计规范.docx VIP
- GB50461-2024:石油化工静设备安装工程施工质量验收规范.pptx VIP
- 2023年浙江省军队转业干部录用考试试题.docx VIP
- 口渴了-朋友帮你.ppt VIP
- Xikong西莱克低温机控制板SHXK814用户手册.pdf
- 爱迪生牛顿大发明攻略.doc VIP
- 重庆天齐锂电新材料有限公司新建1000吨_年高能锂电材料电池级金属锂项目环评报告.pdf VIP
- 朗文3A复习资料及垃圾分类作文8篇.doc VIP
- DB65T 3694-2015 现行哈萨克文与西里尔哈萨克文编码字符转换规则.docx VIP
- 华为云服务登录.doc VIP
原创力文档

文档评论(0)