YTU 2705:用重载求距离
2024-08-24 22:42:13
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));
}
最新文章
- 玩转github----1
- Tigase数据库结构(1)
- 避开unity的坑(转摘)
- Java多线程实现
- 使用NBU进行oracle异机恢复
- Java基础之线程——使用Runnable接口(JumbleNames)
- Maven学习随记
- Android -- 获取汉字的首字母
- Portlet 通信过程详解
- c语言,strcmp(),字符串比较,看Asic 码,str1>;str2,返回值 >; 0;两串相等,返回
- SQLServe错误整理
- Android 通过外键连接两个数据库
- Windows - 程序猿应该熟记的CMD常用命令
- python使用get在百度搜索并保存第一页搜索结果
- javaweb项目环境搭建,jdk,tomcat,myeclipse,sqlserver安装 配置
- linux添加超级管理员用户,修改,删除用户
- SVN-Failed to run the WC DB work queue associated with
- 微服务之Sping Cloud
- loadrunner提高篇 - 关联技术的经典使用
- HDU 1072 Nightmare (广搜)
热门文章
- 安卓app测试之cpu监控
- java虚拟机(八)--java性能监控与故障处理工具
- nginx+keepalived+tomcat+memcache实现双VIP高可用及Session会话保持
- layer实现窗口抖动效果
- HDU - 2041 - 超级楼梯(dp)
- oop设计模式抽象总结
- codeforces round #394 (div. 2) A\B 题解
- Wow! Such Sequence! (线段树) hdu4893
- [K/3Cloud] KSQL日期常量用法注意
- canvas裁剪之后的base64转换为上传文件blob对象