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; ]; ], ...
随机推荐
- 如何在网页中浏览和编辑DWG文件 梦想CAD控件
如何在网页中浏览和编辑DWG文件 梦想CAD控件 www.mxdraw.com 梦想绘图控件5.2 是国内最强,最专业的CAD开发组件(控件),不需要AutoCAD就能独立运行.控件使用VC 201 ...
- react native 从头开始
1.react-native run-android 报错SDK location not found. Define location with sdk.dir in the local.prope ...
- 【转载】linux下的zookeeper启动
zookeeper的安装目录:/usr/local/zookeeper-3.4.6/bin/zkServer.sh; 配置文件路径:../conf/zoo.cfg 端口 :2181: ZooKeepe ...
- 洛谷——P1120 小木棍 [数据加强版]
P1120 小木棍 [数据加强版] 题目描述 乔治有一些同样长的小木棍,他把这些木棍随意砍成几段,直到每段的长都不超过5050. 现在,他想把小木棍拼接成原来的样子,但是却忘记了自己开始时有多少根木棍 ...
- 创建sum求多元素的和
a = [1, 2, 3] b = [4, 5, 6] def sum_super(* args): s = 0 for i in args: s += sum(i) return s # print ...
- Balanced Numbers(数位dp)
Description Balanced numbers have been used by mathematicians for centuries. A positive integer is c ...
- poj 3253 Fence Repair(priority_queue)
Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 40465 Accepted: 13229 De ...
- 54. spring boot日志升级篇—logback【从零开始学Spring Boot】
在<44. Spring Boot日志记录SLF4J>章节中有关相关的介绍,这里我们在深入的了解下logback框架. 为什么要使用logback ? --在开发中不建议使用System. ...
- 搭建Kafka运行环境-Mac版
停止kafka服务: kafka_2.12-0.10.2.1> bin/kafka-server-stop.sh kafka_2.12-0.10.2.1> bin/zookeeper-se ...
- G - 免费馅饼 基础DP
都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼.说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内.馅饼如果掉在了地上当然就 ...