1 / 8

算法案例的应用习题分析

第一章 单元复习. 第三课时. 算法案例的应用习题分析. INPUT m , n. DO. r=m MODn. m=n. n=r. LOOP UNTIL r=0. PRINT m. END. 例 1 阅读下列程序:若输入的两个数 m=428 , n=284 ,求计算机输出的数. 4. 例 2 求 324 , 243 , 270 三个数的最大公约数. 27. 例 3 已知 f(x)=8x 7 +5x 6 +3x 4 +2x+1, 用秦九韶算法去 f(2) 的值. f(x)=((((((8x+5)x+0)x+3)x+0)x+0)x+2)x+1.

jeremy-good
Download Presentation

算法案例的应用习题分析

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 第一章 单元复习 第三课时 算法案例的应用习题分析

  2. INPUT m,n DO r=m MODn m=n n=r LOOP UNTILr=0 PRINT m END 例1 阅读下列程序:若输入的两个数m=428,n=284,求计算机输出的数. 4

  3. 例2 求324,243,270三个数的最大公约数. 27 例3 已知f(x)=8x7+5x6+3x4+2x+1,用秦九韶算法去f(2)的值. f(x)=((((((8x+5)x+0)x+3)x+0)x+0)x+2)x+1 f(2)=1397

  4. 例4 用秦九韶算法求多项式f(x)=anxn+an-1xn-1+…+a1x+a0的值,令 v0=an,vk=vk-1x+an-k (k=1,2,…,n). 若f(x)=3x5+4x4+5x3+2x2+2x+1,当x=3时,求v4的值. V4=270

  5. 例5 把十进制数104化为三进制数. 104=10212(3) 例6 把八进制数2376(8)化为五进制数. 2376(8)=1278=20103(5)

  6. 例7 在等式 3×6528=3 ×8256中,方框内是同一个一位数,编写一个程序,判断该数是否存在,若存在,输出x的值.

  7. x=1 开始 x=1 a=10x+3 b=30+x A=a×6528 B=b×8256 否 A≠B? 是 x=x+1 输出x 否 x>9? 是 输出x不存在 结束 DO a=10x+3 b=30+x A=a*6528 B=b*8256 IF A<>B THEN x=x+1 LOOP UNTIL x>9 PRINT x不存在 ELSE PRINT x END IF END

  8. 作业: P51复习参考题B组:1,3.

More Related