感谢支持
我们一直在努力

Linux计算器运算的程序文件

  你们知道什么是Linux计算器么这个非常高深的运用技术将由我来非常讲解,Linux计算器NB在哪呢,下面我来进入讲述Linux计算器的无限领域。


  19–bc Linux计算器


  [root@CentOS4 ~]# bcbc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty’. (interrupt) use quit to exit.(interrupt) use quit to exit.quit[root@CentOS4 ~]# Linux计算器在bc上常用的运算符有:+加法-减法*乘法/除法(在没有设置scale精确度时候,自动取整)^指数%求余数(取模)在bc上还可以使用++ 变量– 变量 变量 ++ 变量 —


  [root@CentOS4 ~]# bcbc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty’. 1+23234+23/2*326725^315625100%40100%238quit[root@CentOS4 ~]# [root@CentOS4 ~]# bc bc 1.06Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty’. scale=2 /*scale=number*/11/42.7511/33.66quit[root@CentOS4 ~]#


  Linux计算器说明:scale=2 是设置小数精确度。/*备注部分*/ www.6688.cc


  bc还可以运行一个Linux计算器带有复杂运算的程序文件(这属于bc的一个扩展属性),如:The following is code that uses the extended features of bc to implement a simpleprogram for calculating checkbook balances. This program is best kept in a file so that it can be used many times withouthaving to retype it at every use.


  Linux计算器使用vi建立一个test运算程序:root@CentOS4 ~]# vi testscale=2print “”nCheck book program!”n”print ” Remember,deposits are negative transaction.”n”print “Initial balance?”;bal=read()bal /= 1print “”n”while (1){“current balance = “;bal”transaction?”;trans =read()if(trans == 0) break;bal -= trans bal /= 1}


  ”test” [New] 14L, 268C written[root@CentOS4 ~]# ls计算结果:[root@CentOS4 ~]# bc “testbc 1.06 Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.This is free software with ABSOLUTELY NO WARRANTY.For details type `warranty’. Check book program!Remember,deposits are negative transaction.Initial balance?560current balance = 560.00transaction?400current balance = 160.00transaction?100current balance = 60.00transaction?0quit[root@CentOS4 ~]#


  今天Linux计算器就学到这些,发现很多内容非常的有意思。就近来的学习总结出,要想学好Linux计算器,重要一点是英语要学好。虽然大致的意思能看明白,但很吃力,经常金山词霸来查某一个单词的意思,这样往往浪费了很多的时间在解决单词的意思。

赞(0) 打赏
转载请注明出处:服务器评测 » Linux计算器运算的程序文件
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏