Dynamically allocated arrays in C++

Avoid hard coding the sizes of arrays in your solutions. Instead of writing
char cArr[10];
int iArr[20][10];
cArr[2] = 'x';
iArr[5][6] = 1;
write
char *cArr = new char[10];

int **iArr = new int*[20];
for (int r = 0; r < 20; r++)
  iArr[r] = new int[10];

cArr[2] = 'x';
iArr[5][6] = 1;

Problems with Visual C++ 6.0

Visual C++ 6.0 does not conform to the C++ standard (with good reason -- it was released before the standard was finalized). g++ 3.0 and higher (which is what is used for scoring) does a better job of conforming to the standard. As a result, some code that compiles under VC++ 6.0 will be scored as not working. So far, the only difference of note is how variables declared in the header of for statements are handled. The following is legal in VC++ 6.0:
int total = 0;
for (int i = 0; i < 10; i++)
  total += i;

i = 0;
Note that the scope of i is the point of declaration to the end of the block the for statement is in. The C++ standard says the scope should be just the for loop itself; this is how g++ works. You cannot fix the above code by redeclaring i after the loop because then VC++ will complain that i is redeclared. We suggest that you write code to the C++ standard and then fix it when VC++ complains by using different variable names. "Compile Error" results stemming from this issue will count in the overall scoring. You have been warned.

Reading from standard input in Java

Input from standard input (usually the keyboard) is done through the System.in object wrapped inside a BufferedReader object. For example, to read input from standard input until there is no more, you can use the following code.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Input
{
    public static void main(String[] args) throws IOException
    {
	BufferedReader stdin
	    = new BufferedReader(new InputStreamReader(System.in));

	String input;
	while ((input = stdin.readLine()) != null)
	    {
		// input is a complete line of input
		// do with it whatever it is you need to do
	    }
    }
}

To read more than one thing on a line, you can read the entire line into a String with readLine as above and then use a StringTokenizer object to break the string apart. For example, the following code reads two integers given on the same line from standard input and outputs their product.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

public class Multiply
{
    public static void main(String[] args) throws IOException
    {
	BufferedReader stdin
	    = new BufferedReader(new InputStreamReader(System.in));

	String input = stdin.readLine();
	StringTokenizer tok = new StringTokenizer(input);

	int left = Integer.parseInt(tok.nextToken());
	int right = Integer.parseInt(tok.nextToken());

	System.out.println(left * right);
    }
}