-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP150.java
More file actions
39 lines (36 loc) · 1.24 KB
/
P150.java
File metadata and controls
39 lines (36 loc) · 1.24 KB
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
package buclesAnidados;
//accepted
import java.util.Scanner;
public class P150 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String nombre = sc.nextLine();
String [] parts = nombre.split(" ");
int lados = Integer.parseInt(parts[0]);
char caracter = parts[1].charAt(0);
while (lados!=0 || caracter!='0') {
for (int i = 0; i < lados; i++) {
for (int j = 0; j < lados - i - 1; j++) {
System.out.print(" ");
}
for (int j = 0; j < lados + 2 * i; j++) {
System.out.print(caracter);
}
System.out.println();
}
for (int i = 1; i < lados; i++) {
for (int j = 0; j < i; j++) {
System.out.print(" ");
}
for (int j = 0; j < (lados*2)+(lados-2)-2*i; j++) {
System.out.print(caracter);
}
System.out.println();
}
nombre = sc.nextLine();
parts = nombre.split(" ");
lados = Integer.parseInt(parts[0]);
caracter = parts[1].charAt(0);
}
}
}