johny doe

Ranch Hand

Posts: 78

posted 10 years ago

we got an integer array of 4 cell

in which we have 3 cells equal

how do i write a loop that adds these 3 cells

another example to my problem may be an array of 6 cells

in which we get 3 cells equal to 7

and 3 cells equal to 8

and the two type are scrambled between each other

i want to calculate separatly the sum of each type of cell

so i get on integer x 24

and on integer y 21

i tried to solve this proble by a for loop

inside of a for loop

but it counts the same possibilities more than one time

how do i solve this problem??

in which we have 3 cells equal

how do i write a loop that adds these 3 cells

another example to my problem may be an array of 6 cells

in which we get 3 cells equal to 7

and 3 cells equal to 8

and the two type are scrambled between each other

i want to calculate separatly the sum of each type of cell

so i get on integer x 24

and on integer y 21

i tried to solve this proble by a for loop

inside of a for loop

but it counts the same possibilities more than one time

how do i solve this problem??

Campbell Ritchie

Marshal

Posts: 56584

172

Consider Paul's rocket mass heater. |