当前位置:网站首页>Area of basic exercise circle ※
Area of basic exercise circle ※
2022-06-13 02:07:00 【Jerry-hao】
import math
r = int(input())
s = r*r*math.pi
print('%.7f'%s)
I don't know if I can import math
So an awkward afternoon ...
subject : Enter the radius , The area of the output circle , It is required to keep after the decimal point 7 position
PI=3.14159265358979323
r = int(input())
kk = r*r*PI
print('kk is :',kk)
s = str(r*r*PI)
for i in range(len(s)):
if s[i]=='.':
w = s[0:i+8]
w = float(w)
print(w)
if int(s[i+8])>=5:
print(' Finally confirm : ',w)
w = w + 0.0000001
print(w)


Finally, it is confirmed that there is no problem , Add one 0.0000001 Just ok 了
however , Add a 0.000000100000005
I remember , The teacher said before , Floating point numbers are stored approximately in a computer . This explains the phenomenon .
Can you beat me up ?
false AC
PI=3.14159265358979323
r = int(input())
s = str(r*r*PI)
s = list(s)
for i in range(len(s)):
if s[i]=='.':
if int(s[i+8]) >=5:
s[i+7]=chr(ord(s[i+7])+1)
for j in range(i+8):
print(s[j],end='')
break

Guess the cause of error : Retain 4 Decimal place ~ 0.23995 +0.0001
actual = 0.2400
Program --->0.2390 ( Only on the th day after the decimal point 4 Bit plus 1)
( ̄ε(# ̄)
really ~ AC
PI=3.14159265358979323
r = int(input())
s = str(r*r*PI)
ss = r*r*PI
for i in range(len(s)):
if s[i]=='.':
if int(s[i+8])>=5:
ss += 0.0000001
sss = str(ss)
for j in range(i+8):
print(sss[j],end='')
边栏推荐
- The execution results of i+=2 and i++ i++ under synchronized are different
- Get started quickly cmake
- [the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] GPIO and register
- Bluetooth module: use problem collection
- [the second day of actual combat of smart lock project based on stm32f401ret6 in 10 days] (lighting with library function and register respectively)
- Looking at Qianxin's "wild prospect" of network security from the 2021 annual performance report
- STM32 sensorless brushless motor drive
- Application circuit and understanding of BAT54C as power supply protection
- Day 1 of the 10 day smart lock project (understand the SCM stm32f401ret6 and C language foundation)
- [work notes] xr872 codec driver migration and application program example (with chip debugging method)
猜你喜欢

General IP address, account and password of mobile IPv6 optical cat login, and mobile optical cat is in bridging mode

dfs与bfs解决宝岛探险

万字讲清 synchronized 和 ReentrantLock 实现并发中的锁

Ctrip reshapes new Ctrip

Vscode configuration header file -- Take opencv and its own header file as an example

The new wild prospect of JD instant retailing from the perspective of "hour shopping"

记录:如何解决MultipartFile类的transferTo()上传图片报“系统找不到指定的路径“问题【亲测有效】

I didn't expect that the index occupies several times as much space as the data MySQL queries the space occupied by each table in the database, and the space occupied by data and indexes. It is used i
![[programming idea] communication interface of data transmission and decoupling design of communication protocol](/img/cd/896d1bcad556ffcbf1007bc984afeb.jpg)
[programming idea] communication interface of data transmission and decoupling design of communication protocol

拍拍贷母公司信也季报图解:营收24亿 净利5.3亿同比降10%
随机推荐
Magics 23.0如何激活和使用视图工具页的切片预览功能
Devexpress implementation flow chart
Learning notes 51 single chip microcomputer keyboard (non coding keyboard and coding keyboard, scanning mode of non coding keyboard, independent keyboard, matrix keyboard)
[printf function and scanf function] (learning note 5 -- standard i/o function)
CXGRID keeps the original display position after refreshing the data
[work notes] the problem of high leakage current in standby mode of dw7888 motor driver chip
Vivo released originos ocean, and the domestic customized system is getting better and better
js获取元素
万字讲清 synchronized 和 ReentrantLock 实现并发中的锁
Padavan mounts SMB sharing and compiles ffmpeg
SQL Server 删除数据库所有表和所有存储过程
STM32 IIC protocol controls pca9685 steering gear drive board
华为设备配置CE双归属
Decoding iFLYTEK open platform 2.0 is a fertile land for developers and a source of industrial innovation
Using atexit to realize automatic destruct of singleton mode
I didn't expect that the index occupies several times as much space as the data MySQL queries the space occupied by each table in the database, and the space occupied by data and indexes. It is used i
Parameter measurement method of brushless motor
Alertwindowmanager pop up prompt window help (Part 1)
Delphi implements adding a column of serial number to the CXGRID list
Devaxpress Chinese description --tcximagelist (enhanced image list control)