谁不喜欢毕达哥拉斯定理a^2+b^2=c^2?用任何接受值a和b并打印出The hypotenuse of this right triangle is c的语言编写最短的方法。将c保持在小数点后的三位。
发布于 2014-02-05 18:42:54
'The hypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2测试:
'The hypotenuse of this right triangle is',3⍕.5*⍨+/⎕*2
⎕:
9 10
The hypotenuse of this right triangle is 13.454解释:
⎕*2:将输入中的值提高到第二次幂+/:取之和.5*⍨:将结果提高到0.5次方3⍕:四舍五入至小数点3位发布于 2014-02-05 18:17:53
print'The hypotenuse of this right triangle is %.3f'%abs(input()+1j*input())关于低音
的PJ
老师:“你能告诉我什么是低音吗?”LJ:“低音,一个简单的问题。如果昨晚有一个高调的派对,你在报纸上读到了,它叫做”高党新闻“。
发布于 2014-02-06 15:04:16
글坼各갠方終加감半方갾밈乘增貶껠矽녆둥긆둹댆뭴뉖멵댶넠닶눠덆둩댲걲늖덨덂건댦땡닦덬뉒걩댲밀⓶期望输入为两个数字(可以是小数!)被一个空间隔开。
这比APL短,尽管不得不使用一些不方便的技巧。
글坼 | split at space
各 | for each...
갠方 | to the power of two
終
加 | add
감半方 | to the power of one half
갾밈乘 | multiply by 1000
增貶 | increment, then decrement (kludge for rounding)
껠矽 | insert '.' at 4th-last character position
녆둥긆둹댆뭴뉖멵댶넠닶눠덆둩댲걲늖덨덂건댦땡닦덬뉒걩댲밀⓶ | "The hypotenuse..."https://codegolf.stackexchange.com/questions/20115
复制相似问题