DevX Home Today's Headlines   Articles Archive   Tip Bank   Forums

1. Registered User
Join Date
Nov 2007
Posts
18

## element

How to choose one element from each array., Which A(i)+B(i)+C(i)+D(i)+E(i)+F(i) must equal to 10.

__________________________________________________
i A B C D E F
__________________________________________________
1 3 2 3 3 2 4
__________________________________________________

2 6 9 4 24 5 7
__________________________________________________

3 11 28 5 81 10 12
__________________________________________________

4 18 65 6 192 17 19
__________________________________________________

5 27 126 7 375 26 28
__________________________________________________

6 38 217 8 648 37 39
_________________________  Reply With Quote

2. how 10 ?
if we use the minimal element in each array we get the sum of elements in the first row (i=1) which is greater than 10
please explain more what's wanted ? and if you have some algorithm mention it or its name.  Reply With Quote

3. Originally Posted by Amahdy
and if you have some algorithm mention it or its name.
Better still, post it.  Reply With Quote

4. Registered User
Join Date
Nov 2007
Posts
18
like this, but I want to choose one elemet from each array, which the sum of A(i)+B(i)+C(i)
+D(i)+E(i)+F(i)=10. Which mean the value of i.

Code:
```int total = 0;
for(int i = 0;i<10;i++)
{
total = a[i] + b[i] + c[i] + d[i] + e[i];
if(total==10)
{
printf("total is 10");
}
total=0;
}```  Reply With Quote

5. your psted code will never be true for the given array
and a[i] is the value of the element number "i" in the array "a" ...
if you mean the value of "i" what can we do with the array ?? here is some example : 3+2+2+1+1+1 ... but I'm sure this is not what's wanted here , please tell me exactly what you want to do ?  Reply With Quote

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
• 