Skip to content

Instantly share code, notes, and snippets.

@YuerLee
Created December 23, 2017 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YuerLee/846e919407e1da7980467c717df97a7d to your computer and use it in GitHub Desktop.
Save YuerLee/846e919407e1da7980467c717df97a7d to your computer and use it in GitHub Desktop.
變形乘法表
#include <stdio.h>
#include <stdlib.h>
int main() {
int length, n;
scanf("%d %d", &length, &n);
for (int i = 1; i <= n; i += length) {
printf("\n");
for (int j = 1; j <= 9; j++) {
// 每列 length 行,但總數不得超過 n 個
for (int col = 0; (col < length) && (i + col <= n); col++) {
printf("%2d * %d ", i + col, j);
}
printf("\n");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment