Hello , I found this puzzle :
typedef struct {
int dd[ 5 ];
int tx;
} node;
node * A = new node[ 10000 ];
for ( int i = 0; i < 100000; i++ ) {
for ( int j = 0; j < A[ i ].tx; j++ ) {
int b = A[ i ].dd[ j ];
a[ i ] = a[ i ] + q[ b ];
}
}
which says to find any errors ( if any) and solve it! Without any other information or data.
I can see two things here:
1) The size of the node A is 10000 but the first loop goes until 100000.So , this is wrong right?
2) The "dd" has size 5 ,so the second loop must go until 5 ,hence A[ i ].tx = 5 ,right?
I can't solve though..
Could you please help me with this?
Tahnks!