All pastes #274132 Raw Edit

Someone

public text v1 · immutable
·published 2006-12-10 13:23 UTC
rendered paste body
import java.lang.Math;

public class Demo72 {
	
	public static void main(String[] args) {
		boolean[] moi = {
			true,true,true,true,true,
			true,false,false,false,true,
			true,false,false,false,true,
			true,false,false,false,true,
			true,true,true,true,true
		};
		nelio(moi);
	}
	
	/**
	 * AE: taulukko.length = n * n
	 *     && n >= 3
	 *     && taulukko != null
	 */

	public static void nelio(boolean[] taulukko) {
		double root = Math.sqrt(taulukko.length);
		int pituus = (int)root;
		String piirros = toistettuna('*', pituus) + "\n";
		for (int i = 0; i < pituus - 2; i = i + 1) {
			piirros += "*" + toistettuna(' ',pituus - 2) + "*\n";
		}
		piirros += toistettuna('*', pituus);
		System.out.println(piirros);

	}

	public static String toistettuna(char merkki, int n) {
		String toisto= "";
		for (int i = 0; i < n; i = i + 1) {
			toisto += merkki;
		}
		return toisto;
	}
}