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
_________________________
5 1732
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
_________________________
Please POST what you have tried to achieve this?
- //total up the array
-
//total + = total + a[i]
-
total += a[i]
but, tehre is b,c,d,e,f ..i diont know ho w to do
- //total up the array
-
//total + = total + a[i]
-
total += a[i]
but, tehre is b,c,d,e,f ..i diont know ho w to do
You want a(i) + b(i) + c(i) + d(i) + e(i) = 10 right?
You try something like this: -
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;
-
}
-
Why must total=0;?
and why == ? - printf("total is 10");
-
}
-
total=0;
-
}
Why must total=0;?
and why == ? - printf("total is 10");
-
}
-
total=0;
-
}
== is a relational operator used in IF for comparison. You can learn about fundamentals of C here
And regarding total = 0, I have reinitialized the total variable so that next time it will store the sum for second value ie for i = 1 and so on.
Its always good to reinitialize/clear a variable value before using them again
Sign in to post your reply or Sign up for a free account.
Similar topics
by: D. Alvarado |
last post by:
Hello,
I have an array that contains numbers. Each element in the array
is guaranteed to be unique. Let's say I have another variable which I
know for certain is in the array, but I don't know...
|
by: Noah Spitzer-Williams |
last post by:
Hello guys,
I'm itinerating through my array using pointers in this fashion:
image is unsigned char image
do {
cout << "image byte is: " << *image << endl;
|
by: lucy |
last post by:
Hello comp.lang.js.I need a script to rotate a background image on
each newpage load, given the id of the element and a list (array?)of 2 or
more image paths ("img1.jpg", "img2.jpg", ...).Actually,...
|
by: Haobin |
last post by:
Hi everyone,
I have an ArrayList whose members are classes. These classes are derived from a same base class. The base class has a floating point array and a string. How do I access each element in...
|
by: Amrit Kohli |
last post by:
Hello.
I have the following code, to do a simple operation by copying the elements
of a vector of strings into an array of char pointers. However, when I run
this code, the first element in the...
|
by: bienwell |
last post by:
Hi all,
Data displayed on the datalist control is bound by the column name of the
dataset like this :
<%# DataBinder.Eval(Container.DataItem, "title")%>
Could I use an element of the array...
|
by: ssg31415926 |
last post by:
I need to compare two string arrays defined as string such that the
two arrays are equal if the contents of the two are the same, where
order doesn't matter and every element must be unique.
...
|
by: Michael Bray |
last post by:
Let's say I am using reflection to analyze my classes, and I have an array
of another class. How do I get the base class that forms the array from a
type?
public class A
{
}
A MyArray =...
|
by: Gestorm |
last post by:
Suppose we have an array a, the idea is: build another array, int
next, for each 0<i<N, next = next position of a in the sorted
array, if a is the max, then next is undefined. For example, let
the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |