📄 例4.6.txt
字号:
例4.6 编写一个程序,用来求两个整数或3个整数中的最大数。如果输入两个整数,程序就输出这两个整数中的最大数,如果输入3个整数,程序就输出这3个整数中的最大数。
#include <iostream>
using namespace std;
int main( )
{int max(int a,int b,int c); //函数声明
int max(int a,int b); //函数声明
int a=8,b=-12,c=27;
cout<<″max(a,b,c)=″<<max(a,b,c)<<endl; //输出3个整数中的最大者
cout<<″max(a,b)=″<<max(a,b)<<endl; //输出两个整数中的最大者
}
int max(int a,int b,int c) //此max函数的作用是求3个整数中的最大者
{if(b>a) a=b;
if(c>a) a=c;
return a;
}
int max(int a,int b) //此max函数的作用是求两个整数中的最大者
{if(a>b) return a;
else return b;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -