본문 바로가기

미래(2015-2016)/자습

마름모 찍기



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
/*
    2015.08.26
    내용: 문제4. 다음처럼 모니터에 출력하세요.
            *
           ***
          *****
           ***
            *
*/
 
#include <stdio.h>
 
int main()
{
    int i;
    int j;
 
    printf("\n");
 
    for (i = 1; i < 6; i++)
    {
 
        for (j = 1; j < 16; j++)
        {
            if (i < 4)
            {
                if (j >= 14 - i && j <= 12 + i)
                    printf("*");
                else
                {
                    printf(" ");
                }
            }
            else
            {
                if (j >= i + 8 && j <= 18 - i)
                {
                    printf("*");
                }
                else
                {
                    printf(" ");
                }
            }
        }
        printf("\n");
    }
    printf("\n\n");
 
    return 0;
}
cs


starPrint.c