Hi,
I have like array
a[2][3]+b[2][3]=c[2][3]
can some tell how to calc both in carray
=====================
Hi,
I have like array
a[2][3]+b[2][3]=c[2][3]
can some tell how to calc both in carray
=====================
I'm not quite sure if this is what you're asking, so I'll explain in a little more detail.
You say you have two arrays, and you want to add each element of the similar indexes to a new array total. Like for instance if you had two weeks of data by day, you'd have each week and a totalIf this is the case, then you need to loop through your arrays and total each index at one time.Code:Week 1 Week 2 Total Sun 50 62 112 Mon 66 61 127 Tue 45 53 98 Wed 57 60 117 etc...Code:for(int i = 0; i < ROW; i++) for(int j = 0; j < COL; j++) arryTot[i][j] = arry1[i][j] + arry2[i][j];
Last edited by SlyMaelstrom; 06-03-2006 at 12:31 PM. Reason: A really dumb error
Sent from my iPadŽ
Thanks for ur .....
Plz I need some like this.
A [1][1] b[1][1] C
1 2 2 6 3 8
4 5 + 4 2 = 8 7
I need calc A array + arryB result in C array.
for(i=0;i<2;i++)
for(j=0;j<2;j++)
cin>>[i][j] /* this will add element of A
for(i=0;i<2;i++)
for(j=0;j<2;j++)
cin>b[i][j];/*** this i am add B elemnt is that correct.
now
How I will sum a[][]+b[][]
then save in c[][]
Ineed that loop
for I need some like c
thx
Last edited by miziri; 06-03-2006 at 03:41 AM.
Code:const int arr_size = 2; const int arr_size2 = 3; int a[arr_size][arr_size2] = {2, 3, 5, 6, 8, 6}; int b[arr_size][arr_size2] = {1, 4, 7, 5, 4, 1}; int c[arr_size][arr_size2]; for (int i = 0; i != arr_size; ++i) { for (int z = 0; z != arr_size2; ++z) { c[i][z] = a[i][z] + b[i][z]; } }
Originally Posted by brewbuck:
Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.
Thanks alot.
I will try that.
Final.
Plz
I have this array
A
1 5 6
2 7 8
3 4 2
exchnage
with first line with last to be liker this
3 4 2
2 7 8
1 5 6
Thax-Iraq
Did you try to sort the array in decending order with any one of the sort algorithms? My suggestion of course, hinges on the fact that an array[x][y] is also an array[xy], and sorting the first row would result in an order like the one you want.
friend
Sort wll not solve my problem in my example sort will be I want code all
example.
thx
Show your attempt at writing the exchange code. It is very much like a simple swap, except you would want to loop through the columns of the rows being swapped, rather than just a simple assignment.
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*