编写函数max()求两个整数中最大的数,主函数负责接收两个数,并调用函数max()和输出结果

来源:百度知道 编辑:UC知道 时间:2024/05/05 00:01:04

void main()
{
int max(int x,int y);
int a,b;
scanf("%d,%d",&a,&b);
printf("%d",max(a,b));
}
int max(int x,int y)
{
return (x>y?x:y);
}

类型没说阿?

max(int a,int b) /*int 指类型也可用其它的,要看main传递的参数*/
{
if (a<b)
a=b;
printf("The maxer number is: %d \n",a);
}

#include "stdafx.h"
#include <iostream.h>
#include <process.h>

int Max(int p_iA, int p_iB)
{
return p_iA > p_iB ? p_iA : p_iB;
}

int main(int argc, char* argv[])
{
int iA = 0;
int iB = 0;

cout<<"please input number a :";
cin>>iA;
cout<<"please input number b :";
cin>>iB;

cout<<"the max number is: "<<Max(iA, iB)<<endl;

system("pause");
return 0;
}

#includ