-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEmptySquare.java
More file actions
39 lines (37 loc) · 836 Bytes
/
EmptySquare.java
File metadata and controls
39 lines (37 loc) · 836 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Autora: Ana laura Madrigal García
// Programa para generar un cuadrardo vacío de asteriscos de lado n
import java.util.Scanner;
class EmptySquare
{
public static void main(String[] args)
{
Scanner leer= new Scanner(System.in);
int n= leer.nextInt();
for (int i=0; i<n; i++)
{
if(i==0 || i==n-1) //la i van a ser los renglones, en el primer reneglón y en el último, tendremos lleno de asteriscos
{
for(int j=0; j<n; j++) //la j serán las columnas (o también el relleno del cuadrado)
{
System.out.print("*");
}
System.out.println();
}
else
{
for(int j=0; j<n; j++)
{
if(j==0 || j==n-1)
{
System.out.print("*");
}
else
{
System.out.print(" ");
}
}
System.out.println();
}
}
}
}