问题描述
嗨
我有一个问题..
函数floor的应用程序ia将值舍入到最接近的整数。陈述y = floor(x + 0.5);将数字x舍入为最接近的整数,并将结果赋给y。我们如何编写一个读取多个数字的程序,并使用前面的语句将每个数字四舍五入到最接近的整数。对于每个进行的数字,打印原始数字和四舍五入的数字。
hi
i have a question..
An application of function floor ia rounding a value to the nearest integer. the statement y=floor(x+0.5); rounds the number x to the nearest integer and assigns the result to y. how can we write a program that reads several numbers and uses the preceeding statement to round each of these numbers to the nearest integer. for each number proceeded, print both the original number and the rounded number.
推荐答案
你可以有一个循环从键盘读取x的值,用y = floor(x + 0.5)计算y;并打印x和y
you could have a loop which reads the value of x from the keyboard, calculates y using y=floor(x+0.5); and prints x and y
这篇关于帮助完成楼层计划的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!