shell脚本,通过传参求斐波那契数列如(0,1,1,2,3,5,8,13..........)
[root@localhost wyb]# cat fibo.sh
#!/bin/bash #斐波那契数列 ,,,,,,, echo > file
echo >> file count=$ for i in `seq $count`
do
first=$(tail - file |head -)
two=$(tail - file)
echo $((first+two)) >> file
done
cat file
[root@localhost wyb]# bash fibo.sh [root@localhost wyb]# bash fibo.sh [root@localhost wyb]#
第二种方法,通过间接赋值来来传。用到read -p [root@localhost wyb]# cat 2fibo.sh
#!/bin/bash #斐波那契数列 ,,,,,,, echo > file
echo >> file #count=$
read -p "Please Input a number:" count
for i in `seq $count`
do
first=$(tail - file |head -)
two=$(tail - file)
echo $((first+two)) >> file
done
cat file
[root@localhost wyb]# bash 2fibo.sh
Please Input a number: [root@localhost wyb]# bash 2fibo.sh
Please Input a number: [root@localhost wyb]# bash 2fibo.sh
Please Input a number: [root@localhost wyb]#
shell脚本,通过传参求斐波那契数列如(0,1,1,2,3,5,8,13..........)的更多相关文章
- C# 求斐波那契数列的前10个数字 :1 1 2 3 5 8 13 21 34 55
//C# 求斐波那契数列的前10个数字 :1 1 2 3 5 8 13 21 34 55 using System; using System.Collections.Generic; using S ...
- 【poj3070】矩阵乘法求斐波那契数列
[题目描述] 我们知道斐波那契数列0 1 1 2 3 5 8 13…… 数列中的第i位为第i-1位和第i-2位的和(规定第0位为0,第一位为1). 求斐波那契数列中的第n位mod 10000的值. [ ...
- 黑马入学基础测试(三)求斐波那契数列第n项,n<30,斐波那契数列前10项为 1,1,2,3,5,8,13,21,34,55
.获得用户的输入 计算 3打印就行了. 这里用到了java.util.Scanner 具体API 我就觉得不常用.解决问题就ok了.注意的是:他们按照流体的方式读取.而不是刻意反复 ...
- golang 闭包求斐波那契数列
题目是Go指南中的闭包求斐波那契数列 package main import "fmt" // 返回一个"返回int的函数" func fibonacci() ...
- 用JS,求斐波那契数列第n项的值
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...
- 01-封装函数求斐波那契数列第n项
<!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...
- python3 求斐波那契数列(Fibonacci sequence)
输出斐波那契数列的前多少个数. 利用函数 #!/usr/bin/env python # -*- coding:utf-8 -*- # Author:Hiuhung Wan # ----斐波那契数列( ...
- 求斐波那契数列的第n项
问题描述:斐波那契数列是这样的一个数列,1,1,2,3,5,8,..,即前两项都是1,后面每一项都是其前面两项的和. 现在要你求出该数列的第n项. 分析:该问题是一个经典的数列问题,相信大家在很多语言 ...
- SPOJ 5152 Brute-force Algorithm EXTREME && HDU 3221 Brute-force Algorithm 快速幂,快速求斐波那契数列,欧拉函数,同余 难度:1
5152. Brute-force Algorithm EXTREME Problem code: BFALG Please click here to download a PDF version ...
随机推荐
- 根运动 (Root Motion) – 工作原理
http://blog.csdn.net/myarrow/article/details/45505085 1. 基本概念 在Unity3D动画中,模型的位置.角度经常会发生变化,我们需要决定是否将模 ...
- VR相关网站
VR87870 http://www.87870.com/ VR玩家网 http://www.vrwanjia.cn/ VR之家 http://www.vr.cn/ http://gad.qq.com ...
- mysql count 中使用case when 带条件及去重
SELECT CASE (SELECT NOW() > '2019-02-12 16:48:00') WHEN 1 THEN '男' WHEN 2 THEN '女' ELSE '未知' END ...
- ARP数据包
结构ether_header定义了以太网帧首部:结构arphdr定义了其后的5个字段,其信息用于在任何类型的介质上传送ARP请求和回答:ether_arp结构除了包含arphdr结构外,还包含源主机和 ...
- Codeforces 1119E(贪心)
题目传送 贪心方法 按边从小到大扫,先凑3个,没凑足的记录一下数量,后面大的优先跟这些凑,俩带走一个,多余的再凑3个,再--就这样走到最后即可. const int maxn = 3e5 + 5; i ...
- Codeforces 526F Pudding Monsters
先把题目抽象一下: 有一个静态的数组,求有多少个区间[i,j]满足:j-i==max{ai,...,aj}-min{ai,...,aj} 也就是要求max-min+i-j==0的区间数 所以肿么做呢? ...
- ZOJ How Many Nines 模拟 | 打表
How Many Nines Time Limit: 1 Second Memory Limit: 65536 KB If we represent a date in the format ...
- Unity EditorWindow知识记录
1.创建EditorWindow using UnityEditor; using UnityEngine; public class ZZEditorWindow : EditorWindow { ...
- 后端 node 项目工具集
后端 node 项目工具集 editor vs code webstorm 质量检查 eslint prettier 命令行相关 better-run-npm npm-run-all nodemon ...
- java错误笔记
错误1. Description Resource Path Location Type The superclass "javax.servlet.http.HttpSer ...