標籤:shell指令碼的基本演算法編程
第一題:斐波那契數列的遞迴與非遞迴
非遞迴:
650) this.width=650;" src="http://s1.51cto.com/wyfs02/M00/82/EF/wKiom1dl-8rD92igAAB-pImrC88891.png-wh_500x0-wm_3-wmp_4-s_582408408.png" title="數列非遞迴圖片.png" alt="wKiom1dl-8rD92igAAB-pImrC88891.png-wh_50" />
遞迴:
650) this.width=650;" src="http://s5.51cto.com/wyfs02/M00/82/EE/wKioL1dmAtGDO4NBAADA3Qh0kR0840.png-wh_500x0-wm_3-wmp_4-s_2210701244.png" title="遞迴圖片.png" alt="wKioL1dmAtGDO4NBAADA3Qh0kR0840.png-wh_50" />
注意在shell下return的範圍是0-255,在這不能用return1
第二題:字串截取cut
650) this.width=650;" src="http://s4.51cto.com/wyfs02/M02/83/00/wKioL1doloqwCEvpAABqPWtm1m8093.png-wh_500x0-wm_3-wmp_4-s_3006264771.png" title="字串截取.png" alt="wKioL1doloqwCEvpAABqPWtm1m8093.png-wh_50" />
第三題:求100個數的和
第一種非遞迴:
650) this.width=650;" src="http://s4.51cto.com/wyfs02/M01/83/01/wKiom1doma3gMPqOAAB1EPzrEaQ509.png-wh_500x0-wm_3-wmp_4-s_1076067697.png" title="求和非遞迴.png" alt="wKiom1doma3gMPqOAAB1EPzrEaQ509.png-wh_50" />
第二種遞迴
650) this.width=650;" src="http://s5.51cto.com/wyfs02/M02/83/01/wKioL1dopv_CuJktAABv4l07Yd4719.png-wh_500x0-wm_3-wmp_4-s_4142792152.png" title="求和遞迴.png" alt="wKioL1dopv_CuJktAABv4l07Yd4719.png-wh_50" />
第三種工具
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/83/01/wKioL1dop3jiCWHbAAAck5VGulc203.png-wh_500x0-wm_3-wmp_4-s_1167999526.png" title="求和工具.png" alt="wKioL1dop3jiCWHbAAAck5VGulc203.png-wh_50" />
第四題:求三個數的最大值,最小值,平均值
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M01/83/02/wKiom1dop7iw7htOAACLVaC7GTc429.png-wh_500x0-wm_3-wmp_4-s_1182994542.png" title="三個數的平均值,最大最小值.png" alt="wKiom1dop7iw7htOAACLVaC7GTc429.png-wh_50" />
shell指令碼的基本演算法編程