YTU 2705:用重载求距离
2705: 用重载求距离.
时间限制: 1 Sec 内存限制: 128 MB
提交: 208 解决: 114
题目描述
使用函数重载的方法定义两个重名函数,分别求出整型数的两点间距离和浮点型数的两点间距离.只需提交两个函数即可。
#include <iostream>
#include <cmath>
using namespace std;
double func(int,int,int,int),func(double,double,double,double);
int main( )
{ cout<<func(2,2,5,5)<<endl;
cout<<func(2.2,2.2,5.5,5.5)<<endl;
return 0;}
输入
输出
样例输出
4.24264
4.6669
你 离 开 了 , 我 的 世 界 里 只 剩 下 雨 。 。 。
#include <iostream>
#include <cmath>
using namespace std;
double func(int,int,int,int),func(double,double,double,double);
int main()
{
cout<<func(2,2,5,5)<<endl;
cout<<func(2.2,2.2,5.5,5.5)<<endl;
return 0;
}
double func(int x1,int y1,int x2,int y2)
{
return sqrt(pow((x1-x2),2)+pow((y1-y2),2));
}
double func(double x1,double y1,double x2,double y2)
{
return sqrt(pow((x1-x2),2)+pow((y1-y2),2));
}
#include <cmath>
using namespace std;
double func(int,int,int,int),func(double,double,double,double);
int main()
{
cout<<func(2,2,5,5)<<endl;
cout<<func(2.2,2.2,5.5,5.5)<<endl;
return 0;
}
double func(int x1,int y1,int x2,int y2)
{
return sqrt(pow((x1-x2),2)+pow((y1-y2),2));
}
double func(double x1,double y1,double x2,double y2)
{
return sqrt(pow((x1-x2),2)+pow((y1-y2),2));
}
YTU 2705:用重载求距离的更多相关文章
- 牛客网 牛客练习赛11 D.求距离
D.求距离 链接:https://www.nowcoder.com/acm/contest/59/D来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 32768K,其他语言6 ...
- 给定数轴上的n个点,求距离最近的两个点的距离
public class MinimumSpacing { //给定平面上的n个点,求距离最近的两个点的距离. //无从下手的话,先分解问题,分解成简单的,逐个分析,然后再合在一起考虑 //这是个2维 ...
- 2019-8-31-C#-已知点和向量,求距离的点
title author date CreateTime categories C# 已知点和向量,求距离的点 lindexi 2019-08-31 16:55:58 +0800 2018-05-08 ...
- HDU - 3899 JLUCPC(树形dp求距离和)
JLUCPC Dr. Skywind and Dr. Walkoncloud are planning to hold the annual JLU Collegiate Programming Co ...
- C# 已知点和向量,求距离的点
已知一个点 P 和向量 v ,求在这个点P按照向量 v 运行距离 d 的点 B . 已经知道了一个点 P 和他运动方向 v ,就可以通过这个求出距离点 P 为 d 的点 B. 首先把 v 规范化,规范 ...
- 【C++函数题目】重载求数组中最小值的函数
题目来源:https://acm.ujn.edu.cn Time Limit: 1 Sec Memory Limit: 128 MB Description 写一个函数名称为miniElement( ...
- NYOJ题目889求距离
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAsYAAAJ2CAIAAADTwNOXAAAgAElEQVR4nO3dPVLrSteG4W8S5B4IsQ
- 小白月赛13 小A的路径 (矩阵快速幂求距离为k的路径数)
链接:https://ac.nowcoder.com/acm/contest/549/E来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言52428 ...
- cf161d 求距离为k的点对(点分治,树形dp)
点分治裸题,但是用树形dp也能做 /* dp[u][k]表示在u下距离k的点数量 */ #include<bits/stdc++.h> using namespace std; ]; ], ...
随机推荐
- Oracle 把一个用户所有表的读权限授予另一个用户
create user <USER_NAME> identified by <PASSWORD>; grant create session TO <USER_NAME& ...
- js一般用法
<1> 通过id查找html元素 var x=document.getElementById("intro"); <2> 通过标签名查找html元素 v ...
- gym101343 2017 JUST Programming Contest 2.0
A.On The Way to Lucky Plaza (数论)题意:m个店 每个店可以买一个小球的概率为p 求恰好在第m个店买到k个小球的概率 题解:求在前m-1个店买k-1个球再*p ...
- 模板—splay
#include<iostream> #include<cstdio> #define cin(x) scanf("%d",&x) using na ...
- 3D NAND闪存是个啥?让国内如此疯狂
Repost: https://news.mydrivers.com/1/477/477251.htm 上个月底武汉新芯科技主导的国家级存储器产业基地正式动工,在大基金的支持下该项目将投资240亿美元 ...
- 洛谷——P1168 中位数
P1168 中位数 题目描述 给出一个长度为NN的非负整数序列$A_i$,对于所有1 ≤ k ≤ (N + 1),输出$A_1, A_3, …, A_{2k - 1}A1,A3,…,A2k−1 ...
- python之cookbook-day03
第一章:数据结构和算法 1.3 保留最后 N 个元素 问题: 在迭代操作或其他操作的时候,怎样只保留最后有限几个元素的历史记录? 解决方案: 保留有限历史记录正是 collections.deque ...
- list数组排序---stream
import java.util.*;import java.util.stream.Collector;import java.util.stream.Collectors; public clas ...
- SQL函数小记
写一篇笔记,记录一下常见的sql函数,以备之后的查找需要. 算数函数 abs(num):绝对值函数 mod(被除数,除数):求余函数 round(num,保留小数的位数):四舍五入函数 字符串函数 c ...
- Andrew and Chemistry(树的同构)
Andrew and Chemistry(树的同构) 题链 将一棵树转化为最小表示法,将此时的树哈希一下,同时用map进行标记,就可以判断树是否存在同构 #include <map> #i ...