Multiplication by Self-Modification

CJam, 9 8 bytes

A: 1
B: 0
C:  r,(#0q

Try it online in the CJam interpreter.

How it works

(ABcode) e# Push the integer 10 ** len(Bcode).
<SP>     e# Noop. Separates (AB) and C for input reading.
r        e# Read the first whitespace-separated token from STDIN (ABinput).
,(       e# Push the string length minus 1: len(Binput)
#        e# Power operator: 10 ** len(Bcode) len(Binput) # ->
         e#   (10 ** len(Bcode)) ** len(Binput) = 10 ** (len(Bcode) * len(Binput))
0        e# Push an additional 0 to complete len(Bcode) * len(Binput) + 1 zeroes.
q        e# Read the remaining input (C).

CJam, 15 13 11 bytes

A: rl"
B: <SP>
C: <LF>",(*SNq

Try it online in the CJam interpreter.

How it works

e# A

r     e# Read a whitespace-separated token from STDIN.
      e# This reads the input up to the first space, but does not consume it.
l     e# Read the rest of the first line from STDIN.
      e# This reads up to the first linefeed and consumes it.

"     e# Initiate a string.

e# B

<SP>  e# Fill the string with as many spaces as there are copies of B.

e# C

<LF>" e# Terminate the string with a linefeed.
      e# This serves as a delimiter for the `l' command.
,(    e# Compute the length of the string minus 1 (to account for the LF).
*     e# Repeat the string read by `l' that many times.
SN    e# Push a space and a linefeed.
q     e# Read the remaining input (i.e., the second line) from STDIN.

At the end, the stack contains the token read by r, the space produced by *, the space and linefeed pushed by SN and the line read by q. CJam prints all these automatically.


Pyth, 10

A: w*\0hl*w[<newline>
B: 0
C: <empty>

We split the source in two lines. The first line is A, the second line are the Bs. Since A is on the first line, the first w just prints A - easy, done.

In Pyth leading zeroes are seperate tokens, so [00) actually is [0, 0]. Note that the first line ends in l[, and the second line consists of 0000.... So l[ actually counts the number of Bs in this program. The second w reads in the second line of the input - this is the number of Bs of the input. From here it's a simple multiply, increment and outputting that many zeroes.