tile - For starting case so a comma doesn't precede the...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// Arup Guha // 11/3/06 // Written in COP 3503 - solves "tile" problem. // Prints out each way to tile a length of n with 1 and 2 unit tiles. / public class tile { p public static void main(String[] args) { p // One test case. / printTile(5,""); } public static void printTile(int n, String curtiles) { p // This is invalid. if (n == -1) return; r // Print out the tiles we've already laid out. if (n == 0) { i System.out.println(curtiles); return;
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: } // For starting case, so a comma doesn't precede the first tile. if (curtiles.equals("")) { printTile(n-2, "2"); printTile(n-1, "1"); } // We can place a tile of length 2, and from that, do all tilings of // length n-2. // OR // We can place a tile of length 1, and from that, do all tilings of // length n-1. else { e printTile(n-2, curtiles+", 2"); printTile(n-1, curtiles+", 1"); } } }...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online