-
Notifications
You must be signed in to change notification settings - Fork 0
/
printstar.html
60 lines (49 loc) · 1.4 KB
/
printstar.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<script>
// nxn 출력
var input = Number(prompt('한자리 숫자 입력'));
for (i = 0; i < input; i++) {
for (j = 0; j < input; j++) {
document.write('*');
}
document.write('<br>');
}
// 왼쪽 정렬 삼각형 출력
var input = Number(prompt('한자리 숫자 입력'));
for (i = 0; i < input; i++) {
for (j = 0; j <= i; j++) {
document.write('*');
}
document.write('<br>');
}
// 오른쪽 정렬 삼각형 출력하려고 했는데 역삼각형 출력
var input = Number(prompt('한자리 숫자 입력'));
for (var i = input; i > 0; i--) {
for (var j = 0; j < i; j++) {
document.write('*');
}
document.write('<br>');
}
// 오른쪽 정렬 삼각형 출력
var input = Number(prompt('한자리 숫자 입력'));
for (i = 1; i <= input; i++) {
for (j = 1; j <= input; j++) {
if (i + j >= input + 1) {
document.write("*");
} else {
document.write(" ");
}
}
document.write("<br>");
}
</script>
<body>
</body>
</html>