123 C++试写一算法,求随机输入的三个整数的最大值

试写一算法,求随机输入的三个整数的最大值。 

#include<iostream>
using namespace std;

int max(int x, int y, int z)
{
	int t;
	t = x > y ? x : y;
	t = t > z ? t : z;
	return z;
}

int main()
{
	int x,y,z,Max;
	cin >> x;
	cin >> y;
	cin >> z;
	Max = max(x,  y, z);
	cout << "最大值是:" << Max << endl;
	return 0;
}

4 5 6
最大值是:6
请按任意键继续. . .

只写int max就行了。

猜你喜欢

转载自blog.csdn.net/phpstory/article/details/82146913
123