文档详情

高中数学必修三程序大全

pu****.1
实名认证
店铺
DOC
74.50KB
约6页
文档ID:456120829
高中数学必修三程序大全_第1页
1/6

Program and list(应用程序和目录)01. BAS 求和a+aa+aaa+aaaa+....+aaa....a(a大于等1小于等于9的整数 Input “a=”;a Input “n=”;n T=0 S=0 i=1 While i<=n T=10*t+a S=s+t I=i+1 Wend Print “s=”,send 02. BAS 求和a+aa+aaa+aaaa+....+aaa....a(a大于等1小于等于9的整数Input “a=”;a Input “n=”;n T=0 S=0 i=1 While i<=n t=t+a s=s+t t=10*a i=i+1 Wend Print “s=”,send03.BAS 求值 Input “a=”;a; Input “b=”;bPrint “s=”;a^b+b^aEnd04.BAS 求一个数的绝对值Input “x=”;xLet y=abs(x)Print “the number absolute value is”;y05.BAS 求一个数的绝对值Inupt “x=”;xIf x>0 thenPrint “absolute value is”;xelseIf x=0 thenPrint “absolute value is”;0 ElsePrint “abosolute value is”;-xEnd ifEnd ifend06.ABS任给一个自然数a( 输出aaaa…a(n个a组成的n位数)Input “a=”;aInput “n=”;nS=0i=1while i<=n s=s+10^(i-1)i=i+1wendlet s=a*sprint send 07.BAS求和: Input “n=”;n i=1 s=0while i<=n-1 s=s+10^(i-1) i=i+1wendprint “s=”;send08.BAS 解一元二次方程Input “a=”;aInput “b=”;bInput “c=”;cLet d=b^2—4*a*cIf d>=0 thenLet p=-b/(2*a)Let q=SQR(d)/(2*a)If d=0 thenPrint “the equation is one real root”;pElseX1=p+qX2=p-qPrint “two difference root”Print “x1=”;x1;”x2=”;x2End if End if End09.ABS解二元一次方程组 Program:Input a1,b1,c1,a2,b2,c2 m=a1*b2-a2*b1 p=b1*c2-b2*c1 q=c1*a2-c2*a1if m<>0 then x=p/m y=q/m print “x=”;x;”y=”;yelse if p=0 or q=0 then print “this binary linear equation group has numberless solution” else print “this binary linear equation group has no solution” end if end if end 10.BASa∈N,1≦a≦9,求a+aa+aaa+aaaa+....+aaa....a 的值 Program:Input “a=”;aInput “n=”;nLet i=1Let s=0dos=s+10^(i-1)i=i+1loop until i>nlet s=a*sprint :s=”;send11.BAS 求两个正整数的最大公约数 【辗转相除法】program:input “m=”;minput “n=”;nif m0r= m mod nif r=0 thenprint “the greatest common divisor of m and n is”;nelsem=nn=rend ifwendend12.BAS 把三个数a,b,c按从大到小的顺序排列input a,b,cif a=b then if a>=c then if b>=c then print a,b,c else print a,c,b end if else print c,a,b end ifelseif b>=c then if a>=c then print b,a,c else print b,c,a end if else print c,b,aend ifend ifend 14.BAS 任给一个大于1的自然数,判断这个数的奇偶性。

programinput “n=”;nif n=2 then print “the number you input is a prime”else i=2 do r=n mod i i=i+1 loop until i>n-1 or r=0 if r=0 then print “the number is not a prime”elseprint “the number is a prime” end ifend ifend15.BAS求和: input “n=”;ni=1s=0 while i<=n s=s+(i+1)/i i=i+1 wendprint “s=”;send16.BAS求和: input “n=”;n i=1 s=0 do s=s+(i+1)/i i=i+1 loop until i>n print “s=”;send17.求一个数的方根,开方(The extraction of a root of a quantity) (extraction of root)方根,开方 program: input x,n m=1/n y=x^m print y end18.BAS 求一个数的算术平方根 program: input “x=”;x if x>=0 then print “arithmetic square root is”;sqr(x) else print “no arithmetic square root” end ifend19.BAS 判断年份是闰年的程序input “your year is”;xif x mod 4=0 and x mod 100<>0 then print “the year is leap year”else if x mod 400=0 then print “the year is leap year” else print “the year is not leap year” end ifend ifend20.BAS计算当x=1,2,3…20时,函数 的函数值x=1while x <=20 y=x^2-3*x+5 print :x=”;x;”y=’;y x=x+1wendend21.BAS计算当x=1,2,3…20时,函数 的函数值x=1do y=x^2-3*x+5print :x=”;x;”y=’;y x=x+1loop until x>20end22.BAS (阶乘factorial)用程序计算n的阶乘input “n=”;nif n=0 then print “0!=1”else if n>=1 theni=1f=1while i<=nf=f*ii=i+1print “the number factorial is”;f wend end ifend if end如果输出语句改为:print n; “!=”;f则屏幕显示为:n!=f0!=11!=12!=23!=64!=245!=12023.BAS 输出1到100之间的偶数PROGRAM:i=1While i<=100i=i+1r=i mod 2if r=0 thenPrint i;end if WendEnd说明:输出语句末加分号表示按行输出,否则按列输出24.BAS 输出1到100之间的偶数PROGRAM:i=1doi=i+1r=i mod 2if r=0。

下载提示
相似文档
正为您匹配相似的精品文档