Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

plz help me in this logic

Status
Not open for further replies.

alangs

Member level 3
Joined
Feb 5, 2010
Messages
57
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,288
Location
india
Activity points
1,681
anybody plz tell me how to write program for the below logic...
Am having array of a[2000] elements in that i have to increase a count if the numbers are continuously in order for five times like 1,2,3,4,5 for example a[0]=1,a[1]=2,a[2]=3,a[3]=4,a[4]=5, then i have to make a count.....if it is not in order for continuosly five times then i should not increse the count.....finally i have to find out the total count......

--------------------------------------------------------------------------------
 

So, if we start with counter=0, and f.i. the sequence 51,21,22,23,24,25,13 is encountered the counter will be increase by 1, then we will have counter=1.

Let's suppose now to start with counter=0 and the sequence encountered is 51,21,22,23,24,25,26,27,13 you expect to see counter=3 ?
 

No....actually once the sequence is encountered after that we have to start from the next sequence to increase the count.....like 51,21,22,23,24,25,26,27,28,29,30....here i expect to see the counter as 2.
 

Hi alangs!
if the size of the numbers is fixed say, to a byte
1. initialse a buffer of 5 byte length.
2. read entries into the buffer.
3. check whether they're consecutive:
a. if (a[i+1]==a+1) for i=0 to 3
b. if not clear buffer.
c. exit to read
d. increment count and exit to read
4. repeat till array ends

Hope this helps.
take care now bye bye then
 

You have to say whether your subsequences of length 5 are to be non-overlapping or overlapping is allowed - this defines the problem you are trying to solve.
 

1. set your starting point
2. see if the number at the starting point and the next four numbers are consecutive.
3. if they are, increase your count and set the starting point= the old starting point plus 5 (skip past the consecutive sequence)
4. if they are not consecutive, add 1 to the starting point (see if the next 5 are consecutive)
5. Continue at step 2 while the starting point is less than 1997 (the last 5 numbers)
Display the count
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top