Wednesday, August 24, 2011

101 The Blocks Problem

I'll dedicate some time from now on to solve programming problems using Java, as I've used only c++  in the past, and having a working knowledge of java is a must in the professional practice these days.

This is just the beginning as my time is very scarce lately:

[sourcecode language="java"]

package blocks_problem;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(;
String line;
int numBlocks;
line = cin.nextLine();
numBlocks = Integer.parseInt(line);
System.out.println("Our block world has "+numBlocks+" blocks");
while(cin.hasNextLine()) {
line = cin.nextLine();
String tokens[]  = line.split("\\s+");
for(int i=0; i<4; i++){



No comments:

Post a Comment