C++;如何将函数连接到程序? 我是初学者,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; } #包括 #包括 使用名称空间std; 最大整数(整数x,整数y,整数z); int main() { int x,y,z; int max=y; int min=x; coutx; 库蒂; 库茨; 不能只加一个,比如

C++;如何将函数连接到程序? 我是初学者,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; } #包括 #包括 使用名称空间std; 最大整数(整数x,整数y,整数z); int main() { int x,y,z; int max=y; int min=x; coutx; 库蒂; 库茨; 不能只加一个,比如,c++,function,numbers,C++,Function,Numbers,在展示之前 cout<<"Biggest is: "<<max<<endl; cout只需添加一个 在展示之前 cout<<"Biggest is: "<<max<<endl; cout#包括 #包括 使用名称空间std; 最大整数(整数x,整数y,整数z); int main() { int x,y,z; //从用户输入中获取值x、y和z int max=最大值(x,y,z); // ... } #包括 #包括 使

在展示之前

 cout<<"Biggest is: "<<max<<endl;
cout只需添加一个

在展示之前

 cout<<"Biggest is: "<<max<<endl;
cout
#包括
#包括
使用名称空间std;
最大整数(整数x,整数y,整数z);
int main()
{
int x,y,z;
//从用户输入中获取值x、y和z
int max=最大值(x,y,z);
// ...
}
#包括
#包括
使用名称空间std;
最大整数(整数x,整数y,整数z);
int main()
{
int x,y,z;
//从用户输入中获取值x、y和z
int max=最大值(x,y,z);
// ...
}

从main()函数调用最大值函数。简单

#include<iostream>
#include<cmath>
using namespace std;

int maximum(int x, int y, int z);

int main()
{
int x,y,z;

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: "<< maximum (x, y, z) << 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;
}
#包括
#包括
使用名称空间std;
最大整数(整数x,整数y,整数z);
int main()
{
int x,y,z;
coutx;
库蒂;
库茨;

cout从main()函数调用最大值函数。很简单

#include<iostream>
#include<cmath>
using namespace std;

int maximum(int x, int y, int z);

int main()
{
int x,y,z;

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: "<< maximum (x, y, z) << 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;
}
#包括
#包括
使用名称空间std;
最大整数(整数x,整数y,整数z);
int main()
{
int x,y,z;
coutx;
库蒂;
库茨;

当然,移动
最大值
函数的定义(OP在其
main
之后定义)是没有用的,因为他不理解确切的问题。不,移动
最大值
函数的定义(OP在其
main
之后定义)是没有用的很公平,我不明白确切的问题。你的意思是像coutyou意思是像cout