[정올] Beginner_Coder_도형만들기1_구구단2_code1341 (C)

두비니

·

2021. 2. 2. 18:42

 

 

 

#include <stdio.h>

int main() {
	int s, e, flag, i;
	while (1) {
		scanf("%d %d", &s, &e);
		if (s >= 2 && e >= 2 && s <= 9 && e <= 9)
			break;
		else {
			printf("INPUT ERROR!");
		}
	}

	if (s > e)
		flag = -1;
	else
		flag = 1;
	
	for (i = s; i != e; i += flag) {
		for (int j = 1; j <= 9 ; j++){
			printf("%d * %d = %2d   ", i, j, i*j);
			if (j % 3 == 0)
				printf("\n");
		}
		printf("\n");
	}
	for (int j = 1; j <= 9; j++) {
		printf("%d * %d = %2d   ", i, j, i*j);
		if (j % 3 == 0)
			printf("\n");
	}
	printf("\n");

	return 0;
}