[c++]代码库
#include "stdafx.h"
#include "iostream"
using namespace std;
int max1(int x, int y, int z) //3个整数的最大值
{
int m;
int n;
if (x > y)m = x;
else m = y;
if (m > z)n = m;
else n = z;
return(n);
}
double max2(double a, double b,double c)//3个双精度数的最大值
{
double mm;
double nn;
if (a>b)mm = a;
else mm = b;
if (mm>c)nn = mm;
else nn = c;
return(nn);
}
int main()
{
int x, y, z;
double a, b, c;
cout<<"input 3 integers"<<endl;
cin>>x>>y>>z;//输入3个整数
cout<<"最大值为"<<max1(x,y,z)<<endl;//输出其最大值
cout<<"input 3 doubles"<<endl;
cin>>a>>b>>c;//输入3个双精度数
cout<<"最大值为"<<max2(a, b, c)<<endl;//输出其最大值
return 0;
}