Doing/C&C++

2~9단 구구단 출력

YongArtist 2016. 11. 15. 02:37

<문제>

2~9단 구구단을 아래와 같은 패턴으로 출력하시오.

<소스코드>

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <stdio.h>
 
int main() {
 
    int i = 2, j = 1;
 
    while (1) {
        printf("%d * %2d = %2d  ", i, j, i*j);
        i++;
        if (i == 10) {
            printf("\n");
            i = 2;
            j++;
        }
        if (j == 10)
            break;
 
    }
 
 
    return 0;
}
cs