Title Description: Enter a number of lines of code, in accordance with the required format output. Each column of words as far as possible to the left, the word between at least one space.
Idea: Use a string array to find the law. As long as the boundaries are controlled, the rest is simple. Even the test cases are useless because the UVA Web page is not being brushed. Directly to the code quicksubmit, just worry will time out, but the result is surprising, unexpectedly is AC. Two more lanes. By the way, I'm embarrassed to use the regular expression.
Code:
<p>import Java.util.*;import Java.util.regex.matcher;import java.util.regex.pattern;</p><p> public class Main1593 {</p><p> public static void main (string[] args) { scanner scan = new SCA Nner (system.in); pattern p = pattern.compile ("<a target=_blank href=" file://\\s ">\\S</a>+"); string[][] str = new String[1005][1000]; int rows = 0; int[] rowcnt = new INT[1000];&NB Sp; arrays.fill (rowcnt, 0); while (Scan.hasnextline ()) { string line = Scan.nextline (); matcher m = P.matcher (line); int cols = 0; while (M.find ()) { rowcnt[rows] ++; str[rows][cols++] = M.group (); } rows ++; } //system.out.println (rows); int[] MaxLen = new int[ 850]; arrays.fill (maxlen, 0); for (int i=0; i<rows;i++) { for (int j=0; j<rowcnt[i]; J + +) { maxlen[j] = max (Maxlen[j], str[i][j ].length ()); } } for (int i=0; i<rows; i++) { for (int j=0 ; j<rowcnt[i]; J + +) { system.out.print (str[i][j]); if (J < rowcnt[i]-1) for (int k=0; k<=maxlen[j]-str[i][j].length (); k++) System.out.print (""); } system.out.println (); } } public static int Max (int a, int b) { if (a >= b) return a; else & Nbsp;return b; }}</p>
UVa 1593-alignment of Code