当前位置: 首页 > news >正文

做视频网站好做吗aso优化服务

做视频网站好做吗,aso优化服务,网站模块名称,wordpress主题php7目录 1 问题描述 2 解决方案 1 问题描述 问题描述为二维空间中的点设计一个结构体,在此基础上为三角形设计一个结构体。分别设计独立的函数计算三角形的周长、面积、中心和重心。输入三个点,输出这三个点构成的三角形的周长、面积、外心和重心。结果保留…

目录

1 问题描述

2 解决方案

 


1 问题描述

问题描述
  为二维空间中的点设计一个结构体,在此基础上为三角形设计一个结构体。分别设计独立的函数计算三角形的周长、面积、中心和重心。输入三个点,输出这三个点构成的三角形的周长、面积、外心和重心。结果保留小数点后2位数字。
样例输出
与上面的样例输入对应的输出。
例:
数据规模和约定
  输入数据中每一个数的范围。
  例:doule型表示数据。

 


2 解决方案

本题主要考查三角形相关数学知识,刚开始做的时候,我对重心和外心的计算公式一点都记不起来,无语中...,后来,计算外心的时候,也出错,因为没有单独划分出横坐标相等的情况,导致计算出错。

 

具体代码如下:

import java.util.Scanner;public class Main {//计算三角形三条边的长public double[] getABC(double[][] point) {double[] edge = new double[3];double x1 = point[0][0], y1 = point[0][1];double x2 = point[1][0], y2 = point[1][1];double x3 = point[2][0], y3 = point[2][1];edge[0] = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);edge[0] = Math.sqrt(edge[0]);edge[1] = (x1 - x3) * (x1 - x3) + (y1 - y3) * (y1 - y3);edge[1] = Math.sqrt(edge[1]);edge[2] = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);edge[2] = Math.sqrt(edge[2]);return edge;}//计算三角形的周长public double getL(double[][] point) {double[] edge = getABC(point);return edge[0] + edge[1] + edge[2];}//计算三角形的面积public double getS(double[][] point) {double[] edge = getABC(point);double p = (edge[0] + edge[1] + edge[2]) / 2;double S = p * (p - edge[0]) * (p - edge[1]) * (p - edge[2]);  //海伦公式S = Math.sqrt(S);return S;}//计算三角形的外心(PS:三角形外接圆的圆心,外心到三个顶点距离相等)public double[] getExcenter(double[][] point) {double[] center = new double[2];double x1 = point[0][0], y1 = point[0][1];double x2 = point[1][0], y2 = point[1][1];double x3 = point[2][0], y3 = point[2][1];double a , b , c , d ;a = (x1*x1 + y1*y1 - x2*x2 - y2*y2) * (x1 - x3) / 2;b = (x1*x1 + y1*y1 - x3*x3 - y3* y3) * (x1 - x2) / 2;c = (y1 - y2) * (x1 - x3);d = (y1 - y3) * (x1 - x2);center[1] = (a - b) / (c - d);  //外心的纵坐标double e, f;if(x1 != x2) {   //防止出现两点的横坐标相等的情况e = (x1*x1 + y1*y1 - x2*x2 - y2*y2) / (2 * (x1 - x2));f = (y1 - y2) / (x1 - x2);center[0] = e - f * center[1];  //外心的横坐标} else if(x1 != x3) {e = (x1*x1 + y1*y1 - x3*x3 - y3*y3) / (2 * (x1 - x3));f = (y1 - y3) / (x1 - x3);center[0] = e - f * center[1];} else if(x2 != x3) {e = (x2*x2 + y2*y2 - x3*x3 - y3*y3) / (2 * (x2 - x3));f = (y2 - y3) / (x2 - x3);center[0] = e - f * center[1];}return center;  }//计算三角形的重心(PS:三角形中三条边的中线交点)public double[] getBarycenter(double[][] point) {double[] center = new double[2];double x1 = point[0][0], y1 = point[0][1];double x2 = point[1][0], y2 = point[1][1];double x3 = point[2][0], y3 = point[2][1];center[0] = (x1 + x2 + x3) / 3;  //重心的横坐标center[1] = (y1 + y2 + y3) / 3;  //重心的纵坐标return center;}//输出题意结果public void printResult(double[][] point) {double L = getL(point);double S = getS(point);double[] exCenter = getExcenter(point);double[] baryCenter = getBarycenter(point);System.out.printf("%.2f\n",L);System.out.printf("%.2f\n",S);System.out.printf("%.2f",exCenter[0]);System.out.printf(" %.2f\n",exCenter[1]);System.out.printf("%.2f",baryCenter[0]);System.out.printf(" %.2f\n",baryCenter[1]);}public static void main(String[] args) {Main test = new Main();Scanner in = new Scanner(System.in);double[][] point = new double[3][2];for(int i = 0;i < 3;i++) {point[i][0] = in.nextDouble();point[i][1] = in.nextDouble();}test.printResult(point);}
}

 

http://www.lbrq.cn/news/2343997.html

相关文章:

  • 网站建设怎么弄建站服务
  • 广州可以做票务商城的网站公司百度站长收录
  • 互助县公司网站建设客户关系管理系统
  • 免费个人手机网站关键词优化推广策略
  • 新浪做网站/谷歌seo怎么优化
  • 汕头模板网建站/搜索推广营销
  • 温州做美食网站/网络推广方法有哪几种
  • seo擦边球网站/广告公司职位
  • 网站建设社会实践成果/安徽建站
  • 富顺做网站/百度广告官网
  • 网站开发 动易/安卓优化
  • 长春网络建站/seo外链资源
  • 网站图怎么做会高清图片/百度小说排行榜2020
  • 简繁英3合1企业网站生成管理系统/怎样在百度上做广告
  • 广州做网站 timhi/广告安装接单app
  • 黔东网站建设/十大洗脑广告
  • 桂平逗乐游戏招聘网站开发/拉新app推广接单平台
  • 网站建设摘要/优化网站排名
  • 网站建设与seo论文/丁的老头seo博客
  • 学做网站的视频/镇江网站定制
  • 庆阳定制网站/淘宝补流量平台
  • 企业网站优化外包/成都网站推广哪家专业
  • 多后缀域名查询网站/外贸互联网推广的
  • 嘉兴做网站建设的公司/网站自动秒收录工具
  • 网站设计公司佛山/百度热搜词排行榜
  • wordpress翻译教程/当阳seo外包
  • 呼叫中心网站建设/如何注册网址
  • 政府网站谁来做/四川二级站seo整站优化排名
  • 创新网站设计/全国培训机构排名前十
  • 网站建设行业怎么样/seo优化中商品权重主要由什么决定
  • redisson 设置了过期时间,会自动续期吗
  • H2 与高斯数据库兼容性解决方案:虚拟表与类型处理
  • K8S的平台核心架构思想[面向抽象编程]
  • [spring6: Resource ResourceLoader ResourceEditor]-加载资源
  • sqli-labs靶场通关笔记:第11-16关 POST请求注入
  • 技嘉UEFI固件SMM漏洞使系统面临固件植入和持久控制风险