المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Simplification of code



C++ Programming
08-04-2009, 07:24 PM
i have written this code that splits the number of cars T. to the number of paths R in all possible ways. this code but only works when the number of paths are 3. also certain outputs are repeated that are 3 0 0, 0 0 3 and 0 3 0....please give me some help that how can i remove the repetition and also how can i make it generalized all any T and R value.


int R;
int T;

R= count;
T= traf_val;


array A(T+1);
array B(R);
array C(R);
array D(R);
array E(R);

int i,j,x;

int dummy=T;

for(i=dummy+1;i>0;i--)
{
A[dummy]=i-1;
B[0]=A[dummy];
B[1]= dummy-B[0];

for (j=2;j