I've been trying to loop these if but I don't get it, where do I have to put the loop?
public static void Run(int n) {
int l;
int c;
for (l = 1; l <= 2 * n - 1; l++) {
System.out.println("\n");
for (c = 1; c <= 2 * n - 1; c++) {
if ((l == 1) || (l == 2 * n - 1) || (c == 1) || (c == 2 * n - 1)) {
System.out.print('a');
} else if ((l == 2) || (l == 2 * n - 2) || (c == 2) || (c == 2 * n - 2)) {
System.out.print(defLettre(n, 1));
} else if ((l == 3) || (l == 2 * n - 3) || (c == 3) || (c == 2 * n - 3)) {
System.out.print(defLettre(n, 2));
} else if ((l == 4) || (l == 2 * n - 4) || (c == 4) || (c == 2 * n - 4)) {
System.out.print(defLettre(n, 3));
} else if ((l == 5) || (l == 2 * n - 5) || (c == 5) || (c == 2 * n - 5)) {
System.out.print(defLettre(n, 4));
} else {
System.out.print(" ");
}
}
}
}
}
Thing is, the more n becomes the more if I have to input and i don't get how you reunite them.
EDIT:
Thanks for your answer. The program I wanted to do was this:
http://pastebin.com/dKBGjVqj (couldn't paste it correctly here).
I was able to do it, only it was confusing because if n was like 10, I would've to input 10 if..else.
BTW, my program needs to be run under 1s on a 1ghz computer and has to be under 8000 Ko. How can I see for the running under 1s part? I guess the .java size is for the size.