For_04 *을 이용하여 사각형 출력하기

정수를 입력받아 아래와 같이 사각형을 *을 이용하여 출력하기.




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <Windows.h>
 
int main(void) {
 
    int i = 0;
    int j = 0;
    int a = 0;
    int sum = 0;
 
    printf("정수를 입력하세요.\n");
    scanf_s("%d"&a);
 
    for (i = 0; i < a; i++) {
        for (j = 0; j < a; j++) {
            printf("*");
        }
        printf("\n");
    }
     
 
    system("pause");
    return 0;
}
cs

댓글