Rezultati

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

Test Točke Porabljen spomin Porabljen čas Status
#1 20/20 56,246 MiB 0,018 s OK
#2 20/20 35,113 MiB 0,000 s OK
#3 20/20 34,703 MiB 0,000 s OK
#4 20/20 34,121 MiB 0,000 s OK
#5 20/20 34,531 MiB 0,000 s OK

Ocenjevani program (resitev1.java):
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class resitev1 {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String first = br.readLine();

		String[] splt = first.split(" ");
		int vrstice = Integer.parseInt(splt[0]);
		int stolpci = Integer.parseInt(splt[1]);

		// LRLRLR
		String order = br.readLine();

		int[] maxDolz = new int[stolpci];
		String[][] vnos = new String[vrstice][stolpci];
		for (int i = 0; i < vrstice; i++) {
			vnos[i] = br.readLine().split(",");

			// dobimo max dolzino na vsak stolpec
			for (int j = 0; j < maxDolz.length; j++) {
				if (vnos[i][j].length() > maxDolz[j]) {
					maxDolz[j] = vnos[i][j].length();
				}

			}

		}

		StringBuilder out = new StringBuilder();

		// pregled po vrsticah
		for (int i = 0; i < vnos.length; i++) {
			for (int j = 0; j < vnos[i].length; j++) {
				if (vnos[i][j].length() != maxDolz[j]) {
					
//					System.out.println("v ifu");
					// Levo
//					System.out.println(order.charAt(j));
//					System.out.println(maxDolz[j] - vnos[i][j].length());
					if (order.charAt(j) == 'L') {
						out.append(vnos[i][j]);
						for (int space = 0; space < maxDolz[j] - vnos[i][j].length(); space++) {
							out.append(" ");
//							System.out.println("spaceL");
						}
						// Desno
					} else {
						for (int space = 0; space < maxDolz[j] - vnos[i][j].length(); space++) {
							out.append(" ");
//							System.out.println("spaceD");
						}
						out.append(vnos[i][j]);
					}
					
					
				} else {
					out.append(vnos[i][j]);
				}
				
				if (j != vnos[i].length-1) {
					out.append(" | ");
				}
				
			}
			out.append("\n");
		}
		
		System.out.println(out);

	}
}