Write a program that reads three numbers and prints the sum of their minimum and maximum values.
Input : Input consists of three integer numbers.
Output : Print a line with the sum of the maximum and the minimum of the three numbers.
#include <iostream> using namespace std; int main() { int l, m, n; cin >> l >> n >> m; int max, min; if (n < l and n < m) min = n; else if (m < n and m < l) min = m; else min = l; if (n > l and n > m) max = n; else if (m > n and m > l) max = m; else max = l; cout << max+min << endl; }
No comments:
Post a Comment