Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cl.adl.repaso2;
- public class ClaseConMain {
- public static void main(String[] args) {
- /*
- *
- * Confeccionar una cruz adentro de un cuadrado
- *
- *
- */
- int n=21;
- int mitad= n/2;
- int mod = n%2;
- int centro = mitad+mod;
- for (int fila=1; fila<=n; fila++) {
- for (int columna=1; columna<=n; columna++) {
- if(fila==centro || columna==centro || fila==1 || fila==n || columna==1 || columna==n || fila==columna || (fila + columna == n+1) ) { //if(i==1 || j==1 || i==n|| j==n) {
- System.out.print("*");
- }else {
- System.out.print(" ");
- }
- }
- System.out.println(" ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement