Write your question here.
Hi, I have an assignment for my college class that I just can't wrap my head around. Here is the assignment that I am struggling with.
1. Ask user to enter 3 numbers a, b and c. Write a program, which will print the values of
following expressions:
a.
max(a,a+b,a-c) + max(b,2b-c,b+2a)
b.
max(3,c+3a,0) + min(ab-2,3c,ac)
Define functions max and min, which will accept 3 numbers as arguments and return the max
and min of them correspondingly. Use these function in order to calculate the values of the
expressions.
I understand that I have to use arrays, add them together, and then display the result of them, but I don't have the slightest clue about how to do that. So far I have been able to calculate the max from an array, but that's about it. If someone could at least point me in the right direction, it would be greatly appreciated!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
int a[3], i, max;
for (i = 0; i<3; i++)
{
cin >> a[i];
if (i == 0) max = a[i];
if (a[i]>max) max = a[i];
}
cout << "max numb is: " << max << endl;
return 0;
}
|