-
728x90
1.
package ITlick_java.star; public class lick_star1 { public static void main(String[] args) { for (int i = 0; i < 5; i++) { System.out.print("*"); } } }
2.
package ITlick_java.star; public class lick_star2 { public static void main(String[] args) { for (int i = 0; i < 5; i++) { System.out.println("*"); } } }
3.
package ITlick_java.star; public class lick_star3 { public static void main(String[] args) { for (int i = 0; i < 5; i++) { for (int j = 0; j<5;j++){ System.out.print("*"); } System.out.println(); } } }
4.
package ITlick_java.star; public class lick_star4 { public static void main(String[] args) { for (int i = 1; i < 6; i++) { for (int j = 1; j < 6; j++) { System.out.print(i); } System.out.println(); } } }
5.
package ITlick_java.star; public class lick_star5 { public static void main(String[] args) { for (int i = 0; i < 5; i++) { for (int j = 1; j < 6; j++) { System.out.print(j); } System.out.println(); } } }
6.
package ITlick_java.star; public class lick_star6 { public static void main(String[] args) { for (int i = 1; i < 6; i++) { for (int j = 0; j < 5; j++) { System.out.print(i+j); } System.out.println(); } } }
7.
package ITlick_java.star; public class lick_star7 { public static void main(String[] args){ for (int i = 5; i>0; i--) { for (int j = 0; j<5; j++) { System.out.print(i+j); } System.out.println(); } } }
8.
package ITlick_java.star; public class lick_star8 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 0; j <= i; j++) { System.out.print("*"); } System.out.println(); } } }
9.
package ITlick_java.star; public class lick_star9 { public static void main(String[] args) { for (int i = 5; i > 0; i--) { //for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { System.out.print("*"); } System.out.println(); } } }
10.
package ITlick_java.star; public class lick_star10 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 0; j < i; j++) { System.out.print(" "); } for (int j = 5; j > i; j--) { System.out.print("*"); } System.out.println(); } } }
11.
package ITlick_java.star; public class lick_star11 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 4; j > i; j--) { System.out.print(" "); } for (int j = 0; j <= i; j++) { System.out.print("*"); } System.out.println(); } } }
10번 코드에서 for문 위아래만 변경
12.
package ITlick_java.star; public class lick_star12 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 0; j <= i; j++) { System.out.print("*"); } System.out.println(); } for (int i = 5; i > 0; i--) { for (int j = 1; j < i; j++) { System.out.print("*"); } System.out.println(); } } }
13.
뭔가가 안될땐 결과를 다른문자들을 확인하면 좋다.
package ITlick_java.star; public class lick_star13 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 5; i > 0; i--) { for (int j = 0; j < i; j++) { System.out.print("&"); } System.out.println(); } for (int i = 1; i < 5; i++) { for (int j = 0; j <= i; j++) { System.out.print("*"); } System.out.println(); } } }
14.
package ITlick_java.star; public class lick_star14 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 4; i++) { for (int j = 0; j < i; j++) { System.out.print(" "); } for (int j = 5; j > i; j--) { System.out.print("*"); } System.out.println(); } for (int i = 0; i < 5; i++) { for (int j = 4; j > i; j--) { System.out.print(" "); } for (int j = 0; j <= i; j++) { System.out.print("*"); } System.out.println(); } } }
15.
package ITlick_java.star; public class lick_star15 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 4; j > i; j--) { System.out.print(" "); } for (int j = 0; j <= i; j++) { System.out.print("*"); } System.out.println(); } for (int i = 1; i < 5; i++) { for (int j = 0; j < i; j++) { System.out.print(" "); } for (int j = 5; j > i; j--) { System.out.print("*"); } System.out.println(); } } }
16.
package ITlick_java.star; public class lick_star16 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 5; j > i; j--) { System.out.print(" "); } for (int j = 0; j < 2 * i + 1; j++) { System.out.print("*"); } System.out.println(); } } }
17.
package ITlick_java.star; public class lick_star17 { public static void main(String[] args) { for (int i = 5; i > 0; i--) { //for (int i = 0; i < 5; i++) { for (int j = 5; j > i; j--) { System.out.print(" "); } for (int j = 0; j < 2 * i - 1; j++) { System.out.print("*"); } System.out.println(); } } }
공백에 &을 주면 확인하기 용의하다
18.
package ITlick_java.star; public class lick_star18 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 5; j > i; j--) { System.out.print("&"); } for (int j = 0; j < 2 * i - 1; j++) { System.out.print("*"); } System.out.println(); } for (int i = 5; i > 0; i--) { //for (int i = 0; i < 5; i++) { for (int j = 5; j > i; j--) { System.out.print("&"); } for (int j = 0; j < 2 * i - 1; j++) { System.out.print("*"); } System.out.println(); } } }
19.
package ITlick_java.star; public class lick_star19 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 0; i < 5; i++) { for (int j = 5; j >= i; j--) { System.out.print("*"); } for (int j = 0; j < 2 * i + 1; j++) { System.out.print(" "); } for (int j = 5; j >= i; j--) { System.out.print("*"); } System.out.println(); } for (int i = 0; i < 5; i++) { for (int j = 0; j <= i; j++) { System.out.print("*"); } for (int j = 10; j > 2 * i - 1; j--) { System.out.print(" "); } for (int j = 0; j <= i; j++) { System.out.print("*"); } System.out.println(); } } }
20.
package ITlick_java.star; public class lick_star20 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 1; i < 5; i++) { for (int j = 0; j < i; j++) { System.out.print("*"); } for (int j = 10; j > 2 * i - 1; j--) { System.out.print(" "); } for (int j = 0; j < i; j++) { System.out.print("*"); } System.out.println(); } for (int i = 0; i < 5; i++) { for (int j = 5; j > i; j--) { System.out.print("*"); } for (int j = 0; j < 2 * i + 1; j++) { System.out.print(" "); } for (int j = 5; j > i; j--) { System.out.print("*"); } System.out.println(); } } }
21.
package ITlick_java.star; public class lick_star21 { public static void main(String[] args) { //for (int i = 5; i>0; i--) { for (int i = 1; i<5; i++){ for (int j = 0; j<i; j++){ System.out.print(" "); } for (int j = 10; j > 2 * i - 1; j--) { System.out.print("*"); } for (int j = 0; j < i; j++) { System.out.print(" "); } System.out.println(); } for (int i = 0; i < 5; i++) { for (int j = 5; j > i; j--) { System.out.print(" "); } for (int j = 0; j < 2 * i + 1; j++) { System.out.print("*"); } for (int j = 5; j > i; j--) { System.out.print(" "); } System.out.println(); } } }
'JAVA 기본' 카테고리의 다른 글
문자열의 특징 (0) 2021.10.29 Servlet의 기본구성 (0) 2021.05.02 15주차 과제: 람다식 #15 (0) 2021.03.05 14주차 과제: 제네릭 #14 (0) 2021.03.01 13주차 과제: I/O #13 (0) 2021.02.28