example2-11.htm

来自「Visual C++面向对象程序设计教程(配套习题资源)」· HTM 代码 · 共 33 行

HTM
33
字号
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>例2-11</title>
</head>

<body>

<p style="line-height: 150%"><font size="2">#include "iostream.h"<br> 
int max(int x,int y)<br> 
{<br>
&nbsp;&nbsp;&nbsp; int m;<br> 
&nbsp;&nbsp;&nbsp; if(x&gt;y) m=x;<br> 
&nbsp;&nbsp;&nbsp; else m=y;<br> 
&nbsp;&nbsp;&nbsp; return m;<br> 
}<br>
<br>
void main()<br> 
{<br>
&nbsp;&nbsp;&nbsp; int a,b,c;<br> 
&nbsp;&nbsp;&nbsp; cout&lt;&lt;"请输入两个数:";<br>
&nbsp;&nbsp;&nbsp; cin&gt;&gt;a&gt;&gt;b;<br>
&nbsp;&nbsp;&nbsp; c=max(a,b);<br>
&nbsp;&nbsp;&nbsp; cout&lt;&lt;a&lt;&lt;"和"&lt;&lt;b&lt;&lt;"中较大的数是:"&lt;&lt;c;<br>
}</font></p>

</body>

</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?