Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Sum of two arrays

hey
how can i sum 2 int arrays into other int array
CHEERZ
[66 byte] By [mike009] at [2007-11-11 7:06:39]
# 1 Re: Sum of two arrays
Well, if their dimension is 1x1 and they both have the same number of elements, a simple loop should do:

int[] a = {1,2,3};
int[] b = {4,5,6};
int[] c = new int[3];

for(int i=0;i<a.size();i++) {
c[i] = a[i]+b[i];
}
chimps at 2007-11-11 22:39:19 >