hypot函数

C ++ hypot()函数 (C++ hypot() function)

hypot() function is a library function of cmath header, it is used to find the hypotenuse of the given numbers, it accepts two numbers and returns the calculated result of hypotenuse i.e. sqrt(x*x + y*y).

hypot()函数cmath标头的库函数,用于查找给定数字的斜边,接受两个数字并返回斜边的计算结果,即sqrt(x * x + y * y) 。

Syntax of hypot() function:

hypot()函数的语法:

    hypot(x, y);

Parameter(s): x, y – numbers to be calculated hypotenuse (or sqrt(x*x + y*y))

参数: x,y –要计算的斜边数(或sqrt(x * x + y * y) )

Return value: double – it returns double value that is the result of the expression sqrt(x*x + y*y).

返回值: double-它返回double值,该值是表达式sqrt(x * x + y * y)的结果 。

Example:

例:

    Input:
float x = 10.23;
float y = 2.3;
Function call:
hypot(x, y);
Output:
10.4854

C ++代码演示hypot()函数的示例 (C++ code to demonstrate the example of hypot() function)

// C++ code to demonstrate the example of
// hypot() function
#include <iostream>
#include <cmath>
using namespace std;
// main code section
int main()
{float x = 10.23;
float y = 2.3;
// calculate the hypotenuse
float result = hypot(x, y);
cout<<"hypotenuse of "<<x<<" and "<<y<<" is = "<<result;
cout<<endl;
//using sqrt() function
result = sqrt((x*x + y*y));
cout<<"hypotenuse of "<<x<<" and "<<y<<" is = "<<result;
cout<<endl;
return 0;
}

Output

输出量

hypotenuse of 10.23 and 2.3 is = 10.4854
hypotenuse of 10.23 and 2.3 is = 10.4854

翻译自: https://www.includehelp.com/cpp-tutorial/hypot-function-with-example.aspx

hypot函数

hypot函数_hypot()函数与C ++中的示例相关推荐

  1. java函数参数使用冒号_java8中:: 用法示例(JDK8双冒号用法)

    JDK8中有双冒号的用法,就是把方法当做参数传到stream内部,使stream的每个元素都传入到该方法里面执行一下. 代码其实很简单: 以前的代码一般是如此的: public class Accep ...

  2. stl vector 函数_vector :: clear()函数,以及C ++ STL中的示例

    stl vector 函数 C ++ vector :: clear()函数 (C++ vector::clear() function) vector::clear() is a library f ...

  3. stl vector 函数_vector :: push_back()函数,以及C ++ STL中的示例

    stl vector 函数 C ++ vector :: push_back()函数 (C++ vector::push_back() function) vector::push_back() is ...

  4. c语言中vector函数大全,vector :: empty()函数,以及C ++ STL中的示例

    C ++ vector :: empty()函数 矢量::空()是一个库函数"载体"头,它是用来检查给定的矢量是否是一个空的载体或没有,它返回一个真,如果矢量大小为0,否则返回假. ...

  5. stl vector 函数_vector :: crbegin()函数,以及C ++ STL中的示例

    stl vector 函数 C ++ vector :: crbegin()函数 (C++ vector::crbegin() function) vector::crbegin() is a lib ...

  6. main函数参数,在VS中向命令行添加参数的方法

    问题描述 使用main函数的参数,实现一个整数计算器,程序可以接受三个参数,第一个参数"-a"选项执行加法,"-s"选项执行减法,"-m"选 ...

  7. 函数指针--Nginx和Redis中两种回调函数写法

    1.Nginx和Redis中两种回调函数写法 #include <stdio.h>//仿Nginx风格 //结构外声明函数指针类型 typedef void (*ngx_connectio ...

  8. ACMNO.40 C语言-子串 有一字符串,包含n个字符。写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串

    题目描述 有一字符串,包含n个字符. 写一函数,将此字符串中从第m个字符开始的全部字符复制成为另一个字符串. 输入 数字n 一行字符串 数字m 输出 从m开始的子串 样例输入 6 abcdef 3 样 ...

  9. R语言使用basename函数获取数据链接地址中的文件名称(removes all of the path up to and including the last path separator )

    R语言使用basename函数获取数据链接地址中的文件名称(removes all of the path up to and including the last path separator (i ...

  10. pandas使用iteritems函数迭代地查看dataframe中的每个数据列(iterate over each column of a dataframe)

    pandas使用iteritems函数迭代地查看dataframe中的每个数据列(iterate over each column of a dataframe) 目录 pandas使用iterite ...

最新文章

  1. java 操作系统 模拟 daima_求C/C++或java写的比较简单的操作系统的模拟程序
  2. 在现代引擎游戏中使用正确的渲染打光流程
  3. Dockerfile文件创建centos:7,配置JDK8的环境变量,与运行springboot的jar包,的镜像
  4. 使用javamail进行邮件发送
  5. js监听地址栏变化_vue中本地储存也可以实时监听
  6. 买了服务器之后如何操作系统,买了服务器之后如何操作系统
  7. pvid和vid区别,tag口和untag口区别
  8. 客气:是礼貌,更是修养 — 《别输在不会表达上》
  9. 26.Yii 模块(2)
  10. 在中国在行其道的智慧城市,为何折戟多伦多? | 凌云时刻
  11. delphi7的加密算法与 delphi XE+加解密算法
  12. 如何停止线程?stop方法过时弊端
  13. android 手机内存分配,【扫盲贴』关于android手机中RAM(也就是 运行内存)的分配...
  14. 不积跬步 无以至千里
  15. 前端学习——Prop
  16. 常用的数量统计量的计算及统计意义
  17. 个人用微信,支付宝在网站收款实现
  18. 数据库——sql修改主键
  19. 服务器搭建微信会员卡系统,智络会员管理系统如何与微信对接
  20. 浦东创变者 | 查湃智能付斌做水下智能领域的乘风破浪者

热门文章

  1. Linux命令行下感叹号的几个用法
  2. 2.3单链表的基本使用及其cpp示例
  3. java 百度poi_Android应用中使用百度地图API之POI(三)
  4. linux课堂笔记(8)
  5. python axis 0 1_python pandas 中axis值0 1怎么分行还是列
  6. es 删除重复数据_怎么标识并删除SPSS数据库里的“重复个案”?
  7. iphone怎样关闭副屏_小米新设计专利曝光:“Z”型折叠屏手机
  8. Spark初识-Spark基本架构概览使用
  9. C#解密出生日期【C#】
  10. Exchange队列优先级介绍和配置