1) Read two integers from the first line of the input file. Print the two numbers, then print the larger of the two, all on the same line. Separate numbers with spaces.
Example: If the input is
24 87
then print
24 87 87
Download the solution program in BASIC, C, C++, Pascal, or Python.
Download data files:
Space-separated values: file 1a, file 1b
Comma-separated values: file 1a, file 1b
2) Read two whole numbers from the first line of a file. Then print all prime numbers between or equal to the two numbers. Use one line for each prime number that you print.
Example: If the input is
17 25
then print:
17
19
23
Download the solution program in BASIC, C, C++, Pascal, or Python.
Download data files:
Space-separated values: file 2
Comma-separated values: file 2
3) A worker earns 1.5 times the regular pay rate for all hours worked in excess of 40. Given the regular rate of pay and the hours-worked so far this week, and given how much the worker wants to earn this week, compute and print the number of additional hours the worker must work to earn exactly the desired salary. (All input data is on one line.)
Example: A worker earns $10.00 per hour and has worked 30 hours so far this week. She wants to earn $460. Thus, if she works 10 more hours (to get to the overtime threshhold), she will have earned $400 and will still need $60 more. She will need to work 4 more hours to earn the $60, so she needs to work 14 hours more than she already has.
Thus, if the input data is
10.00 30.0 460.00
The correct output is
14.0
Download the solution program in BASIC, C, C++, Pascal, or Python.
Download data files:
Space-separated values: file 3a, file 3b
Comma-separated values: file 3a, file 3b
4) You are given the key to a substitution cypher and some encrypted text. Translate the text into plaintext.
The first line of data will be the key. The first character of the key is the replacement character for 'A'; the second is the replacement for 'B', etc. The key will be exactly 26 characters long. Subsequent lines constitute the cyphertext. The cyphertext will contain mostly characters from the key. It will also contain some "space" (" ") and "endline" characters, which are not encrypted. Print out the decrypted text until the entire message has been decrypted. The plaintext will consist exclusively of capital letters, spaces, and newlines.
Example: If the data is
WHRTNCQZPOYAJSXMUEIDBFGKLV
GZNS PS DZN RXBIN XC ZBJWS NFNSDI
PD HNRXJNI SNRNIIWEL CXE XSN MNXMAN
DX TPIIXAFN DZN MXAPDXRWA HWSTI
GZPRZ ZWFN RXSSNRDNT DZNJ GPDZ WSXDZNE
Then the output should be
WHEN IN THE COURSE OF HUMAN EVENTS
IT BECOMES NECESSARY FOR ONE PEOPLE
TO DISSOLVE THE POLITICAL BANDS
WHICH HAVE CONNECTED THEM WITH ANOTHER
Download the solution program in BASIC, C, C++, Pascal, or Python.
Download data file: file 4
5) Write a program to solve a simple maze. The maze consists of an 8 x 8 grid (like a chessboard), filled with 1's for squares on the path and zeros for squares that are off the path. Rows and columns are numbered from top to bottom and left to right respectively. Thus, the upper left hand square is square 0 0 (if you count from zero), or 1 1 (if you count from one). The path is simple: there are no blind alleys. The path starts somewhere in the top row (Start at the leftmost '1' in the top row.) and ends in the lower right hand square. Each move along the path must be vertical or horizontal; no diagonal movement is allowed. You may not retrace your steps. Each time you find the next (or first) square on the path, write its row number and column number on a new line, with a space between them.
The data file consists of eight 0's and 1's on each of eight lines.
Sample data file:
0 0 0 0 1 0 0 0
0 0 1 1 1 0 0 0
0 1 1 0 0 0 0 0
0 1 0 1 1 1 1 1
0 1 1 1 0 0 0 1
0 0 0 0 0 0 1 1
0 0 0 0 0 0 1 0
0 0 0 0 0 0 1 1
Correct output from sample data file is either
if you count from zero:
0 4
1 4
1 3
1 2
2 2
2 1
3 1
4 1
4 2
4 3
3 3
3 4
3 5
3 6
3 7
4 7
5 7
5 6
6 6
7 6
7 7
or, if you count from one:
1 5
2 5
2 4
2 3
3 3
3 2
4 2
5 2
5 3
5 4
4 4
4 5
4 6
4 7
4 8
5 8
6 8
6 7
7 7
8 7
8 8
Download the solution program in BASIC, C, C++, Pascal, or Python.
Download data files:
Space-separated values: file 5
Comma-separated values: file 5
Return to SRU High School Programming Contest page.
Go to Computer Science Department Page.
Go to Slippery Rock University Home Page.
This page last modified on January 22, 2003.
Page maintained by Michael P. Conlon