1 2 3 4 5 6 7 | echo | awk '{print 19+7}' ==> 26 echo | awk '{print 19-7}' ==> 12 echo | awk '{print 19*7}' ==> 133 echo | awk '{print 19/7}' ==> 2.71429 echo | awk '{print 19**7}' ==> 893871739 echo | awk '{print 19%7}' ==> 5 echo | awk '{print atan2(19, 7)}' ==> 1.21781 |
1 2 3 4 5 6 7 8 9 | { print $1 " + " $2 " = " $1 + $2 print $1 " - " $2 " = " $1 - $2 print $1 " x " $2 " = " $1 * $2 print $1 " / " $2 " = " $1 / $2 print $1 " ^ " $2 " = " $1 ** $2 print $1 " mod " $2 " = " $1 % $2 print " atan2( " $1 " , " $2 " ) " " = " atan2($1, $2) } |
1 2 3 4 5 6 7 8 9 | function fibo(n) { if(n<=1) return 1; return (fibo(n-2) + fibo(n-1)); } BEGIN { n = (ARGV[1] < 1) ? 1 : ARGV[1]; printf("%d\n", fibo(n)); exit; } |
1 2 3 4 5 6 7 8 9 | function factorial(n) { if(n<=1) return 1; return (n*factorial(n-1)); } BEGIN { n = (ARGV[1] < 1) ? 1 : ARGV[1]; printf("%d\n", factorial(n)); exit; } |
1 2 3 4 5 6 7 8 9 10 | BEGIN { a = 3.7; x = a; while((x**2-a)**2 > 1e-12) { x = (x + a/x)/2; } print x } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |