当前位置:网站首页>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='')
边栏推荐
- Introduction to Google unit testing tools GTEST and gmoke
- Swiper horizontal rotation grid
- Review the history of various versions of ITIL, and find the key points for the development of enterprise operation and maintenance
- LeetCode每日一题——890. 查找和替换模式
- DFS and BFS to solve Treasure Island exploration
- Ruixing coffee 2022, extricating itself from difficulties and ushering in a smooth path
- 华为设备配置CE双归属
- 华为设备配置私网IP路由FRR
- [learning notes] xr872 GUI littlevgl 8.0 migration (display part)
- rsync 传输排除目录
猜你喜欢

柏瑞凯电子冲刺科创板:拟募资3.6亿 汪斌华夫妇为大股东
![[the second day of the actual combat of the smart lock project based on stm32f401ret6 in 10 days] light up with the key ----- input and output of GPIO](/img/98/77191c51c1bab28448fe197ea13a33.jpg)
[the second day of the actual combat of the smart lock project based on stm32f401ret6 in 10 days] light up with the key ----- input and output of GPIO

Huawei equipment configures private IP routing FRR

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
![[work with notes] NDK compiles the open source library ffmpeg](/img/24/ed33e12a07e001fc708e0c023e479c.jpg)
[work with notes] NDK compiles the open source library ffmpeg

Yovo3 and yovo3 tiny structure diagram

What did Hello travel do right for 500million users in five years?

uniapp 预览功能

Interruption of 51 single chip microcomputer learning notes (external interruption, timer interruption, interrupt nesting)

万字讲清 synchronized 和 ReentrantLock 实现并发中的锁
随机推荐
Sqlserver2008 denied select permission on object'***** '(database'*****', schema'dbo')
rsync 传输排除目录
记录:如何解决MultipartFile类的transferTo()上传图片报“系统找不到指定的路径“问题【亲测有效】
华为设备配置IP和虚拟专用网混合FRR
[arithmetic, relation, logic, bit, compound assignment, self increasing, self decreasing and other] operators (learning note 4 -- C language operators)
Build MySQL environment under mac
Padavan mounts SMB sharing and compiles ffmpeg
Ruixing coffee 2022, extricating itself from difficulties and ushering in a smooth path
Delphi Google API text to speech MP3 file
Restrict cell input type and display format in CXGRID control
Use mediapipe+opencv to make a simple virtual keyboard
STM32F103 IIC OLED program migration complete engineering code
柏瑞凯电子冲刺科创板:拟募资3.6亿 汪斌华夫妇为大股东
[unity] problems encountered in packaging webgl project and their solutions
[open source] libinimini: a minimalist ini parsing library for single chip computers
js-dom
Ten thousand words make it clear that synchronized and reentrantlock implement locks in concurrency
Huawei equipment configures private IP routing FRR
[work with notes] NDK compiles the open source library ffmpeg
拍拍贷母公司信也季报图解:营收24亿 净利5.3亿同比降10%