I have a question concerning arrays
Let's pretend I have a structure that looks like this:
typedef struct structure
{
char letter1
char letter2
int n1
int n2
Quote:
}structure;
structure array[6];
The following elements of the structure (structure) in the array (array[6])
are repectively letter1, letter2, n1, n2
array[0]... A, B, 5, 0
array[1]... B, C, 4, 0
array[2]... C, D, 7, 0
array[3]... B, A, 3, 0
array[4]... C, B, 2, 0
array[5]... D, C, 7, 0
What I'd like to do is as follow:
Go through the array... for example:
- If there are A, B, 5, 0 in array[0] and B, A, 3,0 in array[3]... then I'd
like to put the n1 value of array[3] in n2 value of array[0] so that
array[0] contains A, B, 5, 3...
- If there are B, C, 4, 0 in array[1] and ,C B, 2,0 in array[4]... then I'd
like to put the n1 value of array[4] in n2 value of array[1] so that
array[1] contains B, C, 4, 2... and so on...
Basically I'd like to check if 2 values of letter1 and letter2 are opposites
in 2 places of the array, then I add the n1 value of the second value in the
n2 of the first one... you got it :)
I'm using C/C++
Many thanks
Nico
--