Contest 1. Contest 2. Contest 3. Contest 4 About this topic Frequently one must use or modify sections of another programmer’s code. Since the original author is often unavailable to explain his/her code, it is essential to be able to read and understand an arbitrary program.
Welcome to the wiki describing the topics covered in the short programs section of the ACSL contests. If you'd like to contribute to this wiki - and we'd love to improve it - please shoot us an email requesting an account.
This category builds these vital skills. In addition, the code fragments used in this category are examples of “good” BASIC programming, and can be studied by students for that purpose. The dialect of BASIC that we will use is ACSL BASIC. The questions will emphasize elementary structured flow of control rather than the particular syntax of the dialect. Students familiar with BASIC or any other high-level language (e.g., Pascal, PL/C, C, FORTRAN), should be able to master this category with just a little additional preparation. Topics covered in the Senior and Intermediate Divisions include (but are not limited to): the evaluation of arithmetic expressions, loops (single and nested), branching, subscripted variables, multi-dimensional arrays, and string manipulations.
In the Junior Division, the specific topic to be tested is given in the title of the category. The following system functions may be used: INT, ABS, LEFT$, RIGHT$, MID$, LEN, VAL, STR$, SQR and SGN. The functions NOT, AND and OR will also be used; they have the order of precedence listed (that is, NOT is highest and OR is the lowest). The following statements may be used: INPUT, DATA, READ, RESTORE, PRINT, TAB, FOR/NEXT, GOTO, GOSUB, RETURN, IF-THEN, IF-THEN-ELSE, LET, REM, DIM, DEF (for user defined functions), END and STOP.
Files and matrix commands will NOT be used. Assume that our programs are immune to syntax errors, variables have enough storage (for example, one doesn’t need an explicit “DIM X(100)” in a program that uses an array with 100 elements). While most commands are functions that are the same on each system, the following frequently vary from system to system. Below we have listed these functions and the interpretation that will be used for the contests. INT(A) returns the largest integer not greater than A.
LEFT$(A$,N) returns a string consisting of the first N characters of the string A$. RIGHT$(A$,N) returns a string consisting of the last N characters of the string A$. MID$(A$,A,B) returns a string consisting of the B characters beginning with the A th character of A$. For example, if A$=”AMERICAN COMPUTER” then MID$(A$,7,5) would equal “AN CO”.
![What Does This Program Do Acsl What Does This Program Do Acsl](http://solutiondots.com/wp-content/uploads/2015/12/HCM-Software.png)
LEN(A$) returns an integer representing the number of characters in the string A$. If A$ is null (A$= “”) then LEN(A$)=0. STR$(A) converts the integer A into a string. Note that an extra space will exist on the left of the string. For example, if A=123 then STR$(A)= “ 123”. VAL(A$) is the inverse to STR$.
This converts the string to its numeric value. The string’s contents must form a valid number. References Golden, Neal.
Computer Programming in the BASIC Language, Harcourt Brace Jovanovich (1981 Kemeny, John G. And Thomas E.
True BASIC, Addison Wesley (1985). Kemeny, John G. And Thomas E. BASIC Programming, John Wiley & Sons (1980). Sample Problems After the following program is executed, what is the final value of B? 10 read H, R 15 data 50, 10 20 B = 0 25 if H A(J) then 60 40 C(L) = B(K) 45 L = L+1 50 K = K+1 55 goto 35 60 C(L) = A(J) 65 L = L+1 70 J = J+1 75 if A(J)0 then 30 80 end The following table traces the variables through the execution of the program. J K L A(J) B(K) C(L) 1 1 1 12 17 12 2 1 2 41 17 17 2 2 3 41 34 34 2 3 4 41 81 41 Thus the value of C(4) is 41.
Note that this program merges two arrays in increasing order into one.