我是 C++ 的初学者,我想做一个找到 3 个数字中最大的程序的程序。由于我无法定义主要发现该功能的功能,我该如何在不使用类的情况下进行操作?感谢您的时间!
#include<iostream>
#include<cmath>
using namespace std;
int maximum(int x, int y, int z);
int main()
{
int x,y,z;
int max=y;
int min=x;
cout<<"Enter 3 numbers to find out which one is bigger. First: ";
cin>>x;
cout<<"Second: ";
cin>>y;
cout<<"Third: ";
cin>>z;
cout<<"Biggest is: "<<max<<endl;
cout<<"Earliest time to meet is: "<<max<<endl;
return 0;
}
//thats the function that checks the biggest number
int maximum (int x, int y, int z)
{
int max = x;
if (y > max) {
max = y;
}
if (z > max) {
max = z;
}
return max;
}