50 lines
901 B
C++
50 lines
901 B
C++
/*
|
|
* input
|
|
* 7 15 3
|
|
* output
|
|
* largest: 15
|
|
* smallest: 3
|
|
*
|
|
* Use functions:
|
|
* int LargestNumber(int num1, int num2, int num3)
|
|
* int SmallestNumber(int num1, int num2, int num3)
|
|
*/
|
|
|
|
#include <iostream>
|
|
using namespace std;
|
|
|
|
/* Define your functions here */
|
|
int LargestNumber(int num1, int num2, int num3){
|
|
int max = num1;
|
|
|
|
if (num2 > max){
|
|
max = num2;}
|
|
if (num3 > max){
|
|
max = num3;
|
|
}
|
|
return max;
|
|
}
|
|
int SmallestNumber(int num1, int num2, int num3){
|
|
int min = num1;
|
|
|
|
if (num2 < min){
|
|
min = num2;}
|
|
if (num3 < min){
|
|
min = num3;
|
|
}
|
|
return min;
|
|
}
|
|
|
|
int main() {
|
|
/* Type your code here. Your code must call the functions. */
|
|
int num1, num2, num3;
|
|
cin >> num1;
|
|
cin >> num2;
|
|
cin >> num3;
|
|
|
|
cout << "largest: " << LargestNumber(num1, num2, num3) << endl;
|
|
cout << "smallest: " << SmallestNumber(num1, num2, num3) << endl;
|
|
|
|
return 0;
|
|
}
|