下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
def c2p puts "Enter x" x=gets.chomp x=x.to_f puts "Enter y" y=gets.chomp y=y.to_f r=Math.sqrt((x**2)+(y**2)) t=Math.atan(y/x) deg=(180*t)/3.14 puts "The coordinate in polar system is ("+r.to_s+","+deg.to_s+")" end def p2c puts "Enter r" r=gets.chomp r=r.to_f puts "Enter angle in degree" t=gets.chomp t=t.to_f x=r*Math.cos((t*3.14)/180) y=r*Math.sin((t*3.14)/180) puts "The coordinate in the cartesian system is ("+x.to_s+","+y.to_s+")" end
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。