1818IP-服务器技术教程,云服务器评测推荐,服务器系统排错处理,环境搭建,攻击防护等

当前位置:首页 - 运维 - 正文

君子好学,自强不息!

Linux计算器运算的程序文件

2022-11-12 | 运维 | gtxyzz | 638°c
A+ A-

你们知道什么是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 是设置小数精确度。/*备注部分*/

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计算器,重要一点是英语要学好。虽然大致的意思能看明白,但很吃力,经常金山词霸来查某一个单词的意思,这样往往浪费了很多的时间在解决单词的意思。

本文来源:1818IP

本文地址:https://www.1818ip.com/post/8868.html

免责声明:本文由用户上传,如有侵权请联系删除!

发表评论

必填

选填

选填

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。