chapter1) 사각형 별찍기
2020. 7. 6. 21:25ㆍPS/etc
public class Q14 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("사각형을 출력합니다");
System.out.print("단 수 : ");
int a = scanner.nextInt();
for (int i = 1; i <= a; i++) {
for (int j = 1; j <= a; j++){
System.out.print("*");
}
System.out.println();
}
}
}
(1)
public class Square_01_14 {
public static void main(String[] args) {
Scanner stdIn = new Scanner(System.in);
int n;
System.out.println("정사각형 모양으로 나타냅니다.");
do {
System.out.print("단수는:");
n = stdIn.nextInt();
} while (n <= 0);
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= n; j++)
System.out.print('*');
System.out.println();
}
}
}
(2)
※참조
Do it! 자료구조와 함께 배우는 알고리즘 입문
'PS > etc' 카테고리의 다른 글
chapter1) 피라미드 별 찍기 (0) | 2020.07.07 |
---|---|
chapter1) 직각 이등변 삼각형 별찍기 (0) | 2020.07.06 |
chapter1) 덧셈표 작성 (0) | 2020.07.06 |
chapter1) 곱셈표 작성 (0) | 2020.07.06 |
chapter1) 양의 정수 자릿수 구하기 (0) | 2020.07.06 |