【发布时间】:2018-02-26 10:06:17
【问题描述】:
对于我在 C++ 中的家庭作业,我的目标是编写一个程序,输入三个整数并将它们传递给一个返回最小数字的函数。这只是我学习 C++ 的第 3 周,所以我不太了解。
此外,我只能以#include<iostream> 和using namespace std 开头。我已经在这几个小时了,这对我来说并不容易。我尝试了很多不同的东西,但我只是得到了错误......
这是到目前为止我真正理解的代码:
#include <iostream>
using namespace std;
int fsmallestNumber(int);
int main() {
int numberOne;
int numberTwo;
int numberThree;
int smallestNumber;
cout << "Enter in 3 numbers and I will find the smallest of all three" << endl;
cin >> numberOne >> numberTwo >> numberThree;
cout << "The smallest of all three numbers is " << smallestNumber << endl;
}
int fsmallestNumber(int sn){
}
我很困惑如何使用 if/else 语句来找到最小的数字,以及如何将最小的数字返回到函数中以打印出来。
【问题讨论】:
-
你试过什么?这里似乎没有任何代码试图解决它。您具体需要哪些方面的帮助?
-
See this link 获取大量有用的信息来解释“如何使用 if/else 语句”。
标签: c++ algorithm if-statement min