Rezultati

Up. imeNalogaJezikRezultatČas oddaje
scnm1-2018 Tabela Java 100/100OK 13. okt '18 @ 10:57

Test Točke Porabljen spomin Porabljen čas Status
#1 20/20 67,441 MiB 0,138 s OK
#2 20/20 37,496 MiB 0,000 s OK
#3 20/20 33,852 MiB 0,000 s OK
#4 20/20 34,648 MiB 0,000 s OK
#5 20/20 37,121 MiB 0,000 s OK

Ocenjevani program (n1.java):
import java.util.*;
import java.io.*;

public class n1 {
	public static String f(String a, int len, char left) {
		boolean l = left == 'L';
		if (l) {
			StringBuilder aa = new StringBuilder(a);
			while (aa.length() < len) {
				aa.append(" ");
			}
			return aa.toString();
		} else {
			StringBuilder aa = new StringBuilder("");
			while (aa.length() + a.length() < len) {
				aa.append(" ");
			}
			aa.append(a);
			return aa.toString();
		}
	}

	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out=new PrintWriter(System.out);
		StringTokenizer st = new StringTokenizer(in.readLine());
		int r = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());
		String allign = in.readLine();
		String[][] tokens = new String[r][c];
		for (int i = 0; i < r; i++) {
			String[] q = in.readLine().split(",");
			for (int j = 0; j < c; j++) {
				tokens[i][j] = q[j];
			}
		}
		int[] max = new int[c];
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				max[j] = Math.max(max[j], tokens[i][j].length());
			}
		}
		//System.out.println(Arrays.toString(max));
		String s = " | ";
		for (int i = 0; i < r; i++) {
			for (int j = 0; j < c; j++) {
				tokens[i][j] = f(tokens[i][j], max[j], allign.charAt(j));
			}
		}
		for(int i=0;i<r;i++) {
			for(int j=0;j<c-1;j++) {
				System.out.print(tokens[i][j]+s);
			}
			System.out.println(tokens[i][c-1]);
		}
	}

}