【C++函数重载】求3个数中最大的数(分别考虑整数、双精度数、长整数的情况)。
2024-09-28 13:53:31
- #include
- using
namespace
std; - int
main( ) - {
- int
max(int a,int
b,int c); //函数声明 - double max(double a,double
b,double c); //函数声明 - long
max(long a,long
b,long c);//函数声明 - int
i1,i2,i3,i; - cin>>i1>>i2>>i3; //输入3个整数
- i=max(i1,i2,i3); //求3个整数中的最大者
- cout<<"i_max="<<i<<endl;
- double d1,d2,d3,d;
- cin>>d1>>d2>>d3; //输入3个双精度数
- d=max(d1,d2,d3); //求3个双精度数中的最大者
- cout<<"d_max="<<d<<endl;
- long
g1,g2,g3,g; - cin>>g1>>g2>>g3; //输入3个长整数
- g=max(g1,g2,g3); //求3个长整数中的最大者
- cout<<"g_max="<<g<<endl;
- }
- int
max(int a,int
b,int c) //定义求3个整数中的最大者的函数 - {
- if(b>a) a=b;
- if(c>a) a=c;
- return
a; - }
- double max(double a,double
b,double c)//定义求3个双精度数中的最大者的函数 - {
- if(b>a) a=b;
- if(c>a) a=c;
- return
a; - }
- long
max(long a,long
b,long c) //定义求3个长整数中的最大者的函数 - {
- if(b>a) a=b;
- if(c>a) a=c;
- return
a; - }
最新文章
- sql server中对xml进行操作
- iOS 自定义emoji表情键盘
- Object -C self -- 笔记
- Linux中查看进程及杀死进程命令
- 递归——CPS(一)
- GlusterFS缺点分析[转]
- sharepoint 创建个人网站
- JAVA Socket编程(二)之TCP通信
- C 上传文件到服务器(含接收端源码)
- 【学习】Python进行数据提取的方法总结【转载】
- Codeforces Beta Round #64D - Professor&#39;s task
- 在ubuntu中我们使用sudo apt-get install 或者dpkg -i *.deb安装软件时,常常提示“有未能满足的依赖关系“,解决方法
- 程序员必知的8大排序(二)-------简单选择排序,堆排序(java实现)
- 提交给mysql java驱动的优化下个版本要发布了^_^
- Linux_Apache 安装
- 180716-Centos时区设置
- 关于fpga优化的set input delay 和 set output delay
- PHP-客户端的IP地址伪造、CDN、反向代理、获取的那些事儿
- 购物单问题—WPS使用excel
- hadoop27---netty中handler的执行顺序
热门文章
- python远程登录Paramiko模块的安装
- 20169219《linux内核原理与分析》第七周作业
- 每次选中数组中的N条数据, 如果让每条数据被选中的次数做到平均??
- ASP.NET MVC实现layui富文本编辑器应用
- 百度AI图片识别
- Repeater+AspNetPager+Ajax留言板
- ldap第一天 编译安装LDAP + ldapadmin
- java中静态代码块的用法 static用法详解和static静态导入
- Spring ThreadPoolTaskExecutor队列满的异常处理
- Eclipse进行Java web开发时,可能会出现这样的错误:The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path