정올 1341 구구단2

1 개요[ | ]

정올 1341 구구단2

2 C[ | ]

#include<stdio.h>

int main() {
    int s, e;
    scanf("%d %d", &s, &e);
    if( s < e ) {
        for(int x=s; x<=e; x++) {
            for(int y=1; y<=9; y++) {
                printf("%d * %d = %2d   ", x, y, x*y);
                if(y%3==0) printf("\n");
            }
            printf("\n");
        }
    } else {
        for(int x=s; x>=e; x--) {
            for(int y=1; y<=9; y++) {
                printf("%d * %d = %2d   ", x, y, x*y);
                if(y%3==0) printf("\n");
            }
            printf("\n");
        }
    }
}

3 C++[ | ]

#include <cstdio>

int main() {
    int s, e;
    scanf("%d %d", &s, &e);
    if( s < e ) {
        for(int x=s; x<=e; x++) {
            for(int y=1; y<=9; y++) {
                printf("%d * %d = %2d   ", x, y, x*y);
                if(y%3==0) printf("\n");
            }
            printf("\n");
        }
    } else {
        for(int x=s; x>=e; x--) {
            for(int y=1; y<=9; y++) {
                printf("%d * %d = %2d   ", x, y, x*y);
                if(y%3==0) printf("\n");
            }
            printf("\n");
        }
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}