PAT (Basic Level) Practice Python解法 1004 成绩排名(和1028/1004类似/平方/开方sqrt)
import sys
import math
n = int(input())
low = math.sqrt(2)*100
high = 0
lowotp = ''
highotp = ''
for i in range(n):
s = sys.stdin.readline()
sl = s.split(' ')#py中的平方是**,开方是sqrt
dis = math.sqrt(abs(int(sl[1]))**2+abs(int(sl[2]))**2)
if dis < low:
low = dis
lowotp = sl[0]
if dis > high:
high = dis
highotp = sl[0]
print(lowotp, highotp)
本文介绍了如何使用Python解决一个涉及距离计算和成绩排名的问题,通过读取输入,计算学生坐标(平方和开方运算)并找到最低和最高分数的学生ID。核心代码展示了如何处理平方和开方操作,以及如何更新最低和最高分记录。
&spm=1001.2101.3001.5002&articleId=120091126&d=1&t=3&u=055cf913e0ed464ca4d46eefdce1cf03)

被折叠的 条评论
为什么被折叠?



