已阅读5页,还剩1页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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 i0 thenPrint “absolute value is”;xelseIf x=0 thenPrint “absolute value is”;0 ElsePrint “abosolute value is”;-xEnd ifEnd ifend06.ABS任给一个自然数a( 输出aaaaa(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=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 m0 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 10BASaN,1a9,求a+aa+aaa+aaaa+.+aaa.a 的值 Program:Input “a=”;aInput “n=”;nLet i=1Let s=0dos=s+10(i-1)i=i+1loop until inlet 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 ab then t=a a=b b=tend ifif ac then t=a a=c c=tend ifif b=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 in-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 in print “s=”;send17.求一个数的方根,开方(The extraction of a root of a quantity) (extraction of root)方根,开方 program: input x,n m=1/n y=xm 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 ifend19BAS 判断年份是闰年的程序input “your year is”;xif x mod 4=0 and x mod 1000 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,320时,函数 的函数值x=1while 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!=12023BAS 输出1到100之间的偶数PROGRAM:i=1While i100End 25BAS 输出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=1dor=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=m m=n n=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 then if n=1 then print “two number is each other prime
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 湖南省永州市新田县2027届九年级上学期11月期中考试历史试卷(含答案)
- 河南省开封市集英中学2026-2027学年上期月考七年级英语(含答案)
- 河北省保定市易县2026-2027学年八年级上学期期中考试语文试题(含答案)
- 仓库保管员安全知识考试试卷及答案
- 人保社会招聘网络笔试题及详细答案
- 交通法规考试模拟试题及详细答案
- 小学四年级道德与法治教学设计:冲突情境中的理性化解与关系重构
- 高中二年级历史教学设计中国古代户籍制度与社会治理机制探究
- 统编版道德与法治八年级上册第五单元第一课《文明有礼》教学设计
- 第四单元 多姿多彩的乐音世界-实践园地《音乐编创-变奏(1)》教学设计-2026-2027学年湘艺版(新教材)初中音乐八年级上册
- 广播电视编辑记者资格考试(广播电视业务)试题及答案(黑龙江省2026年)
- 诸暨文旅集团招录考试题2026
- 医疗机构医保基金使用管理规范
- ISO12944 全套系列标准中文版(完整合集)钢结构防腐涂装规范
- T/UNP 416-2024电连接器轻量化设计指南
- 美国白宫 科学:一个新的黄金时代 致总统的报告
- 2026年广西高考化学试卷(含答案及解析)
- 2026国产AI Agent深度评测报告
- CSCO胰腺癌诊疗指南(2026版)
- 初中历史七年级大单元教学·三国鼎立与统一奠基(部编版)
- (正式版)DB3201∕T 1045-2021 《交通市政基础设施规划编制通则》
评论
0/150
提交评论