hi all,

thanks for time to view my thread.hope u guys can reply.
i have an algorithm,but the question is how can i code from the algorithm?what should i do maybe in steps?
because im really new to programming and i want to know what is the step do we need to do to code base on algorithm

Recommended Answers

All 7 Replies

Post your algorithm and we will, probably, give you hints and nudges to help you increating a method that implements it.

if i have these inputs:
A:a1,a2
B:b1,b2,b3
C:c1,c2
D:d1,d2,d3

FYI, a1,a2,b1,b2,c2,c1 and the rest are values
and i have this interactions:
1)1,1,1,0
2)1,1,0,1
3)1,0,1,1
4)0,1,1,1

base on 1st interaction:
my algorithm is:
A=value B x value C
B=value C
C=alternately
D=x
The total result=value A x value B x value C

and the result for interaction 1,1,1,0 is:
a1,b1,c1,X
a1,b1,c2,X
a1,b2,c1,X
a1,b2,c2,X
a1,b3,c1,X
a1,b3,c2,X
a2,b1,c1,X
a2,b1,c2,X
a2,b2,c1,X
a2,b2,c2,X
a2,b3,c1,X
a2,b3,c2,X

A=2 x 3=6 (6 (a1) and 6 (a2))
B=2 (2 (b1),2(b2) and 2 (b3)
C=1 alternately c1,c2
D=x
The total result=2 x 3 x 2= 12 (row of combination)

the rest interaction:
1,1,0,1
A=value B x value D
B=value D
C=X
D=alternately
The total result=value A x value B x value D

1,0,1,1
A=value C x value D
B=X
C=value D
D=alternately
The total result=value A x value C x value D

0,1,1,1
A=X
B=value C x value D
C=value D
D=alternately
The total result=value B x value C x value D

Create a 2D array where your "inputs" are the "subarrays". Then the interactions are a boolean array where true indicates that the array in that index of the "first" dimension of the 2d array should be used. Then, for the iterations, you write a triple loop outputting the first indexed arrays "current" value with the second indexed arrays "current" value, with the third indexed arrays "current" value and "X" from inside the third loop. Then, for the math, the first "value" is the length of the first indexed array times the length of the second indexed array and the second value is the length of the third indexed array and the total value is both of those values multiplied together.

Now, take that description and attempt to implement it.

Create Class Diagrams or whatever will help you to show needed Classes and methods.
Then Go ahead and code those methods. Review your code, and make necessary changes until you think it is good now.

Design->Code->Debug->Release
That is how I undertake such tasks

Create Class Diagrams or whatever will help you to show needed Classes and methods.
Then Go ahead and code those methods. Review your code, and make necessary changes until you think it is good now.

Design->Code->Debug->Release
That is how I undertake such tasks

its a general advice but its good for me since i have no idea at all to start coding.

Thanks

Create a 2D array where your "inputs" are the "subarrays". Then the interactions are a boolean array where true indicates that the array in that index of the "first" dimension of the 2d array should be used. Then, for the iterations, you write a triple loop outputting the first indexed arrays "current" value with the second indexed arrays "current" value, with the third indexed arrays "current" value and "X" from inside the third loop. Then, for the math, the first "value" is the length of the first indexed array times the length of the second indexed array and the second value is the length of the third indexed array and the total value is both of those values multiplied together.

Now, take that description and attempt to implement it.

ok,i think i understand ur idea.what if i have input like A,B,C,D and E and the binary is 11110,11101,11011,10111,01111. and the algorithm is still the same.but in this case, ihave more than 3 '1'.since like i cant have triple loop isnt?

Recursion.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.