Sewickley Academy Programming Team
Programming Contest:  31-Jan-2002
David Kosbie (Faculty Advisor)
Sewickley Academy

Link to Programming Contests home page.

Quick Questions (SRU-style)

The following programs will be tested with redirection, as in q1.exe < testFile1.txt.

Question 1.  Read in four integers from the first line of the input file.  Print the absolute value of each number, then print the smallest absolute value, then print the difference between the largest and smallest absolute values.  Print these numbers all on the same line, separating the numbers with spaces.

Question 2.  Read in two prime numbers (guaranteed to be prime) from the first line of a file.  Then print all the whole numbers between or equal to the two prime numbers such that at least one of the two primes is a factor of that whole number. Print these numbers out 5 per line, separated by a space.

Question 3.  Read in four integers from the first line of a file.  These are, in order, x1, y1, x2, and y2, and they are endpoints of a non-vertical, non-horizontal line segment.  Print the area of the rectangle that encloses this line segment and whose sides are parallel to the x and y axes.

Question 4.  Read in 10 letters from the first line of a file, and output "YES" if all the letters in the word "dog" occur in those letters, and "NO" otherwise.  Your test must be case insensitive.

Question 5.  Read in a whole number n, followed by n words, separated by spaces, and output the shortest and longest words, separated by spaces.

Question 6.  Read in a whole number n, and output the sum of the exponents of its prime factoring.  For example, if you read in 96040, this equals 235174, so the sum is 3 + 1 + 4, so you would print out 8.

Question 7.  Read in an integer n and a whole number k, where 0 <= k <= 31.  Note that n is a 32-bit integer, where the bit 0 is the low-order (ones) bit, and bit 31 is the sign bit.  Print out bit k of number n.

Question 8.  Read in three numbers and print out the number with the most bits set to 0.

Question 9.  Read in four whole numbers, a, b, c, and d.  You are guaranteed that the product of some of those numbers equals the product of the rest of the numbers.  So, perhaps a = b*c*d, or a*b = c*d, or a*d = b*c.  Print out a line showing the correct equality.  Always place a on the left-hand-side, and on both the left-hand and right-hand sides, list the integers in the same order as given in the input. So, if the input is 3 36 6 2, your output must be 3 * 6 * 2 = 36.

Question 10.  Read in three whole numbers and output "YES" if these can be the sides of a triangle and "NO" otherwise.