1、Program and list(应用程序和目录)01. BAS 求和 a+aa+aaa+aaaa+aaaa(a 大于等1 小于等于 9 的整数Input “a=”;aInput “n=”;nT=0S=0i=1While i0 thenPrint “absolute value is”;xelseIf x=0 thenPrint “absolute value is”;0 ElsePrint “abosolute value is”;-xEnd ifEnd ifend06.ABS任给一个自然数 a( 1,9a输出 aaaaa(n 个 a 组成的 n 位数)Input “a=”;aInput “
2、n=”;nS=0i=1while i=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解二元一次方程组 11220axbycProgram:Input a1,b1,c1,a2,b2,c2 m=a1*b2-a2*b1p=b1*c2-b2*c1q=c1*a2-c2*a1if mnlet s=a*s
3、print :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 thenif a=c thenif b=c thenprint a,b,celseprint a,c,bend ifelseprint c,a,bend ifel
4、seif b=c thenif a=c thenprint b,a,celseprint b,c,aend ifelse print c,b,aend ifend ifend14.BAS任给一个大于 1 的自然数,判断这个数的奇偶性。programinput “n=”;nif n=2 thenprint “the number you input is a prime”elsei=2do r=n mod ii=i+1loop until in-1 or r=0if r=0 thenprint “the number is not a prime”elseprint “the number is
5、 a prime”end ifend ifend15.BAS求和: 34512n input “n=”;ni=1s=0while in print “s=”;send17.求一个数的方根,开方(The extraction of a root of a quantity)(extraction of root)方根,开方program:input x,nm=1/ny=xmprint yend18.BAS求一个数的算术平方根program:input “x=”;xif x=0 thenprint “arithmetic square root is”;sqr(x)else print “no a
6、rithmetic square root”end ifend19BAS 判断年份是闰年的程序input “your year is”;xif x mod 4=0 and x mod 100=1 theni=1f=1while i100End25BAS输出 1 到 100 之间的偶数PROGRAM:i=1dor=i mod 2if r=0 then print i;end if i=i+1loop until i100End26BAS输出 1 到 100 之间的 3 的倍数PROGRAM:i=1While i100End28BAS输出 1 到 100 之间的 3 的倍数PROGRAM:i=1d
7、or=i mod 2if r=0 then print i;end if i=i+1loop until i100End29.BAS 求两个正整数的最大公约数【辗转相除法】program:input “m=”;minput “n=”;nif mn then t=mm=nn=tend if dor= m mod nif r=0 thenprint “the greatest common divisor of m and n is”;nelsem=nn=rend ifloop until r=0end30.BAS 求两个正整数的最大公约数【辗转相除法】the program is :1:input m,n2:if mn thent=mm=nn=tend if 3:r=m mod n4:if r=0 thenif n=1 thenprint “two number is each other prime number”elseprint nend ifelsem=nn=rgoto 3end if5:end30.BAS 求 5 次多项式 43210()fxaxaxa当 时的什值0program :input a5,a4,a3,a2,a2,a1,a0input x0n=1v=a5while n=5i=5-nv=v*x0+ain=n+1wendprint vend