# Combination of checking Values in input

147

Hi

I need to check the combination of my boolean functions which actually are situations that may happen in chart and are in extern. let you explain it by an example.

I have 10 different functions that their names are OPT1, OPT2,.... OPT10.

to check them I have to make groups of them, So I have to check them in different levels. in first level, for the example, we have maximum of 5 group.

the number of groups in each level is  MathCeil((last group number after first level or number of functions for first level)/2)

in each group I need to check three situations: 1. "All of the values in the group are true" 2."One of the Values in the group is true" 3. "None of the values in the group are true."

I write a while in while in while code but it was a mess.

is it possible to code a universal function for this  application if I have more functions but knows the number of functions ?

thanks

Moderator
10411

m_shafiei2006:

in each group I need to check three situations: 1. "All of the values in the group are true" 2."One of the Values in the group is true" 3. "None of the values in the group are true."

set a variable to zero

check each condition and increase the variable if the condition is true

check whether the variable == 5,1 or 0

147

GumRai:

set a variable to zero

check each condition and increase the variable if the condition is true

check whether the variable == 5,1 or 0

I think I couldn't tell you my meaning. this is not my problem, the problem is how to count a series of variable that contain continuous numbers.

for example I have 5 situations;

bool Sit1 ();
bool Sit2 ();
bool Sit3 ();
bool Sit4 ();
bool Sit5 ();

I get the group number of levels of each situation from input and type of each group from extern input,

// group numbers of level 1 from input (up to 3 groups)

extern int

GSit1L1 = 1,
GSit2L1 = 3,
GSit3L1 = 2,
GSit4L1 = 3,
GSit5L1 = 2
;

// group numbers of level 2 from input (up to 2 groups)

extern int

GSit1L2 = 4,
GSit2L2 = 5,
GSit3L2 = 4,
GSit4L2 = 5,
GSit5L2 = 4
;

//group types from input (-1,0,1,2)

extern int

GT1 = -1,
GT2 = 2,
GT3 = 2,
GT4 = 1,
GT5 = 1

;

So if I could count the members of each group and the number of situations that belong to a group, then I can compare and find the result.

I asked a C programmer who doesn't listen carefully and he said it is impossible, another one said you can count a series of variable that contain continuous numbers with arrays, but I don't know how;

or do you have another way to handle it ?

thanks

147

Moderator
10411

I am unable to understand what you are trying to do so am unable to offer any advice.
147

ok,

just tell me how to count a series of variable that contain continuous numbers in a "for" loop .

```extern int

GSit1L1 = 1,
GSit2L1 = 3,
GSit3L1 = 2,
GSit4L1 = 3,
GSit5L1 = 2
;

extern int

GT1 = -1,
GT2 = 2,
GT3 = 2,
GT4 = 1,
GT5 = 1

;

int
GML1GT1,
GML1GT2,
GML1GT3,
GML1GT4,
GML1GT5;

int GML1 ()
{
for (int i=GSit1L1; ; ++)
if (i==GT1)
GML1GT1++
if (i==GT2)
GML1GT2++
if (i==GT3)
GML1GT3++
if (i==GT4)
GML1GT4++
if (i==GT5)
GML1GT5++
if (i==GT6)
}```
the loop is from GSit1L1 to GSit5L1.