【1142】面向对象程序设计上机练习三(有默认参数的函数)

面向对象程序设计上机练习三(有默认参数的函数)

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

利用默认参数的函数实现求2个或3个整数的最大值。

输入

输入3个int型整数。

输出

输出第1、2个整数及其最大值;
输出第1、2、3个整数及其最大值。

示例输入

88 66 99

示例输出

88 66 88
88 66 99 99

#include <iostream>
using namespace std;
int max(int a,int b,int c=-32753)
{ 
	if(a<b)
		a=b;
	if(a<c)
		a=c;
    cout<<a<<endl;
	return 0;
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a<<" "<<b<<" "; 
	max(a,b);
    cout<<a<<" "<<b<<" "<<c<<" ";
	max(a,b,c);
	return 0;
}


posted @ 2014-09-12 09:40  jiangyy  阅读(329)  评论(0编辑  收藏  举报