用VC6.0怎样编这样的一个程序?

来源:百度知道 编辑:UC知道 时间:2024/05/11 20:41:00
自己输入两个数,输出其中较大的。
用? : 函数。
补充说明:需要定义一个max(a,b)的函数。

#include<stdio.h>

main()
{
int i,j,k;
printf("Please input the 1st num\n");
scanf("%d", &i);
printf("Please input the 2nd num\n");
scanf("%d", &j);

if(i>j)
k=i;
else
k=j;
end
printf("K=\n%d", k);
return 0;
}

这是标准的vc语言
#include<iostream>
using namespace std;
void max(int x,int y)
{ int max;
if(x>y)max=x;
else max=y;
cout<<"max="<<max<<endl;

}
int main()
{
int a,b;
cout<<"输入两个数字:"<<endl;
cin>>a>>b;
max(a,b);
return 0;
}