예제 #1
0
파일: Main.java 프로젝트: tasyrkin/SPOJ
 public static void formatMult(BigNumber b1, BigNumber b2, BigNumber[] res) {
   int maxInput = Math.max(b1.bigNumber.length, b2.bigNumber.length + 1);
   int maxLength = Math.max(maxInput, res[res.length - 1].bigNumber.length);
   StringBuffer toFill = new StringBuffer();
   for (int i = 0; i < maxLength - b1.bigNumber.length; i++) {
     toFill.append(" ");
   }
   System.out.println(toFill + b1.toString());
   toFill = new StringBuffer();
   for (int i = 0; i < maxLength - (b2.bigNumber.length + 1); i++) toFill.append(" ");
   System.out.println(toFill + "*" + b2.toString());
   toFill = new StringBuffer();
   if (b2.bigNumber.length != 1) {
     for (int i = 0; i < maxLength - maxInput; i++) toFill.append(" ");
     for (int i = 0; i < maxInput; i++) toFill.append("-");
   } else {
     for (int i = 0; i < maxLength; i++) toFill.append("-");
   }
   System.out.println(toFill);
   for (int i = 0; i < res.length - 1; i++) {
     toFill = new StringBuffer();
     for (int j = 0; j < maxLength - (res[i].bigNumber.length + i); j++) toFill.append(" ");
     System.out.println(toFill + res[i].toString());
   }
   if (b2.bigNumber.length == 1) return;
   toFill = new StringBuffer();
   for (int i = 0; i < maxLength; i++) toFill.append("-");
   System.out.println(toFill);
   toFill = new StringBuffer();
   for (int i = 0; i < maxLength - res[res.length - 1].bigNumber.length; i++) toFill.append(" ");
   System.out.println(toFill + res[res.length - 1].toString());
   // lastMult.size()+Math.max(b1.bigNumber.length-1, b2.bigNumber.length-1);
 }
예제 #2
0
파일: Main.java 프로젝트: tasyrkin/SPOJ
 public static void formatOp(BigNumber b1, BigNumber b2, BigNumber res, String op) {
   int maxLength =
       Math.max(b1.bigNumber.length, Math.max(b2.bigNumber.length + 1, res.bigNumber.length));
   StringBuffer toFill = new StringBuffer();
   for (int i = 0; i < maxLength - b1.bigNumber.length; i++) {
     toFill.append(" ");
   }
   System.out.println(toFill + b1.toString());
   toFill = new StringBuffer();
   for (int i = 0; i < maxLength - (b2.bigNumber.length + 1); i++) {
     toFill.append(" ");
   }
   System.out.println(toFill + op + b2.toString());
   toFill = new StringBuffer();
   for (int i = 0; i < maxLength; i++) {
     toFill.append("-");
   }
   System.out.println(toFill);
   toFill = new StringBuffer();
   for (int i = 0; i < maxLength - res.bigNumber.length; i++) {
     toFill.append(" ");
   }
   System.out.println(toFill + res.toString());
 }