viernes, 15 de noviembre de 2013

EXERCISE
Are extracted file data in "packets" of 100. If the number of data extracted with value greater than 600 and less than 700 is greater than 100 , display the message " meet schedule," indicating the number of extracted data against the total extracted fulfilling . Otherwise, continue to extract data packets ( considered unlimited ) . Raise it in pseudocode and flowchart.


Note: Consider that the data is in an array Data (1 ) Data ( 2) Data ( ... )
SOLUTION
pseudocode :
1. Home [ p100 Data Extraction aprenderaprogramar.com ]
Two . n = 1
Three . As Expected = False Make
3.1 Since i = n to n + 99 Make
Read Data ( i)
If Data ( i ) > 600 and Dato ( i ) < 700 Then
j = j + 1
endif
following
3.2 If j > 100 Then
Expected = True
endif
3.3 If Expected = True Then
Show " schedule is met having extracted" , j, " total data " , n + 99 , "data"
YesNo
Show "Removing a new package "
n = n + 100
endif
repeat
April . end
Comments: Expected boolean functions as a switch to control the main loop as well as decision making through Si ... Then. While their use is unavoidable , use expressions as Expected = True always be lighter and less cumbersome than using algebraic relations more or less complex .
In this algorithm prescindiríamos switch follows:


We modify line 3 : While j < = 100 Make


· We changed the line 3.2 to :
If j > 100 Entoces
Show " schedule is met having extracted" , j, " total data " , n + 99 , "data"
YesNo
Show "Removing a new package "
n = n + 100
endif
· We remove the line 3.3
This option is as valid as the previous one, but more difficult to follow and interpret.

0 comentarios:

Publicar un comentario

deja un comentario