日期:2014-05-17 浏览次数:20705 次
import java.util.*; public class Test { public static void main(String[] args) throws Throwable { BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream("map01.txt"))); String buf = ""; List<List<Integer>> list = new ArrayList<List<Integer>>(); while ((buf=br.readLine()) != null) { if (! buf.matches("(\\d+(\\s+|$)){3,}")) continue; String[] sa = buf.split("\\s+"); int x = Integer.valueOf(sa[0]); int y = Integer.valueOf(sa[1]); int z = Integer.valueOf(sa[2]); while (list.size() < y) { list.add(new ArrayList<Integer>()); } List<Integer> sub = list.get(y-1); while (sub.size() < x) { sub.add(0); } sub.set(x-1, z); } System.out.printf(" "); for (int i=0; i<12; i++) { System.out.printf("%02d ", i+1); } System.out.println(); for (int i=0; i<8; i++) { System.out.printf("%03d||", i+1); if (i<list.size()) { List<Integer> sub = list.get(i); for (int j : sub) { if (j == 0) { System.out.printf(" "); } else { System.out.printf("%02d ", j); } } } System.out.println(); } } }