lab3_2.cpp

来自「几个c++实验程序 对初学者很有帮助的」· C++ 代码 · 共 40 行

CPP
40
字号
//lab3_2.cpp
#include <iostream.h>

int max1(int x, int y)
{
	return (x>y?x:y);
}

int max1(int x, int y, int z)
{
	int temp1=max1(x,y);
	return (y>z?y:z);
}

double max1(double x, double y)
{
	return (x>y?x:y);
}

double max1(double x, double y, double z)
{
	double temp1=max1(x,y);
	return (y>z?y:z);
}

void main()
{
	int x1, x2;
	double d1, d2;
	x1 = max1(5,6);
	x2 = max1(2,3,4);
	d1 = max1(2.1, 5.6);
	d2 = max1(12.3, 3.4, 7.8);

	cout << "x1=" <<x1 << endl;
	cout << "x2=" <<x2 << endl;
	cout << "d1=" <<d1 << endl;
	cout << "d2=" <<d2 << endl;
}

⌨️ 快捷键说明

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