|
Prev: Shareware C Compiler
Next: Calculate Running Time
From: cplusplusquestion on 14 Jan 2008 17:46 Each time initial an array: for(int i=0; i<size; i++) for(int j=0; j<other_size; j++) a[i][j]=0; It is very painful procedure for a massive data., is there any good idea?
From: Francis Glassborow on 14 Jan 2008 18:17 cplusplusquestion(a)gmail.com wrote: > Each time initial an array: > > for(int i=0; i<size; i++) > for(int j=0; j<other_size; j++) > a[i][j]=0; > > It is very painful procedure for a massive data., is there any good > idea? try int a[size][other_size] = {0};
From: Daniel T. on 14 Jan 2008 18:29 cplusplusquestion(a)gmail.com wrote: > Each time initial an array: > > for(int i=0; i<size; i++) > for(int j=0; j<other_size; j++) > a[i][j]=0; > > It is very painful procedure for a massive data., is there any good > idea? int a[5][5] = { 0 };
From: cplusplusquestion on 14 Jan 2008 18:31 On Jan 15, 9:17 am, Francis Glassborow <francis.glassbo...(a)btinternet.com> wrote: > cplusplusquest...(a)gmail.com wrote: > > Each time initial an array: > > > for(int i=0; i<size; i++) > > for(int j=0; j<other_size; j++) > > a[i][j]=0; > > > It is very painful procedure for a massive data., is there any good > > idea? > > try > int a[size][other_size] = {0}; Thanks, but the running time still no change?
From: Francis Glassborow on 14 Jan 2008 18:50 cplusplusquestion(a)gmail.com wrote: > On Jan 15, 9:17 am, Francis Glassborow > <francis.glassbo...(a)btinternet.com> wrote: >> cplusplusquest...(a)gmail.com wrote: >>> Each time initial an array: >>> for(int i=0; i<size; i++) >>> for(int j=0; j<other_size; j++) >>> a[i][j]=0; >>> It is very painful procedure for a massive data., is there any good >>> idea? >> try >> int a[size][other_size] = {0}; > > Thanks, but the running time still no change? bench mark it and find out (I guess that a good compiler will do a good job with that code, but a superb compiler might manage the same job with the nested loop version.
|
Pages: 1 Prev: Shareware C Compiler Next: Calculate Running Time |