V
V
vvafree2016-07-25 20:21:20
Programming
vvafree, 2016-07-25 20:21:20

How to do multiple selection C++?

Good afternoon. How to make multiple selection.
There are 3 variables.

int a = 2;
int b = 1;
int c = 2;

The bottom line is that different combinations - (a, b, c) - correspond to a certain value
For example
(2, 2, 2) is 0
(1, 1, 1) is 1
(2,1,1) is 9
How can you implement given multiple IF.
I tried with switch, but it didn't work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2016-07-25
@vvafree

int res;
if (2 == a && 2 == b && 2 == c)
  res = 0;
else if (1 == a && 1 == b && 1 == c)
  res = 1;
else if (2 == a && 1 == b && 1 == c)
  res = 9;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question