Advertisement
cd62131

take pair number, print decorated box

Oct 19th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.83 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class Chie13115168098 {
  4.   public static void main(String[] args) {
  5.     Scanner in = new Scanner(System.in);
  6.     int h = 0;
  7.     int w = 0;
  8.     StringBuilder sb = new StringBuilder();
  9.     while (true) {
  10.       try {
  11.         if (in.hasNext()) { h = new Integer(in.next()); }
  12.         if (in.hasNext()) { w = new Integer(in.next()); }
  13.       }
  14.       catch (Exception e) {
  15.         in.close(); System.exit(1);
  16.       }
  17.       if (h == 0 || w == 0) { break; }
  18.       for (int i = 0; i < h; i++) {
  19.         for (int j = 0; j < w; j++) {
  20.           if (i == 0 || i == h - 1 || j == 0 || j == w - 1) {
  21.             sb.append("#");
  22.           }
  23.           else {
  24.             sb.append(".");
  25.           }
  26.         }
  27.         sb.append("\n");
  28.       }
  29.       sb.append("\n");
  30.     }
  31.     System.out.print(sb);
  32.   }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement