5.36(Geometry:area of a regular polygon)
来源:互联网 发布:淘宝浅草风是正品吗 编辑:程序博客网 时间:2024/06/05 01:15
问题及代码:package first;import java.util.Scanner;public class MyTriangle {public static void main(String[] args) {System.out.println("请输入一个正多边形的边数和该正多边形的边长:");Scanner a = new Scanner(System.in);double s = 0;int n = a.nextInt();double side = a.nextDouble();while (true) {if (n > 0 && side > 0) {s = area(n, side);System.out.println("该正多边形的面积为:" +s);break;} else {System.out.println("输入非法,请重新输入!");}}}public static double area(int n, double side) {double s = 0;double b = n * side * side;s = (b / (4 * Math.tan((Math.PI / n))));return s;}}运行结果;
1 0
- 5.36(Geometry:area of a regular polygon)
- Algorithm to find the area of a polygon
- LightOJ 1305 Area of a Parallelogram - Basic Geometry
- The Number of Triangles Formed by Intersecting Diagonals of a Regular Polygon
- Regular polygon(HDU 6055)
- HDU6055 Regular polygon(思路)
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Regular polygon
- Area of a Parallelogram
- HDU 4033 Regular Polygon(二分枚举)
- HDU 4195 Regular Convex Polygon(正多边形)
- HDU 4033 Regular Polygon(二分)
- uva 12300 - Smallest Regular Polygon(几何)
- Dlib库的安装配置
- Tomcat 性能优化(连接数、线程、JVM、dir)
- Android 红圈营销项目 —— 自定义柱形图和自定义折线图
- codeforces586A Alena's Schedule(模拟)
- python if __name__ == '__main__' 详解
- 5.36(Geometry:area of a regular polygon)
- 《统计学习方法》+最小二乘拟合多项式系数推导过程+P12推导勘误
- 二叉树前序遍历
- 仿写聊天气泡界面
- iOS UICollectionView 详解
- Android基础入门教程——8.2.1 Bitmap(位图)详解
- tomcat 性能优化
- 蓝懿iOS 技术内容和心得 10。13
- UFT录制与脚本编辑