#include<stdio.h>
int main()
{
int i, j, d, n;
// tittle
printf("【 掛け算の表を出します 】\n");
// input
while (1) {
printf("何進数の表を出しますか(2~10) :");
scanf("%d", &n);
if (n < 2 || 10 < n) {
printf("エラー\n");
} else {
break;
}
}
// show head
printf("\n | ");
for (j = 1; j < n; j++) {
printf(" %d ", j);
}
printf("\n---+");
for (j = 0; j < (n - 1) * 3 + 1; j++) {
printf("-");
}
printf("\n");
// show body
for (i = 1; i < n; i++) // n進数の10の位について
{
printf(" %d | ", i);
for (j = 1; j < n; j++) // n進数の1の位について
{
d = i * j;
d = 10 * (d / n) + d % n;
printf("%2d ", d);
}
printf("\n");
}
// end
return 0;
}
I2luY2x1ZGU8c3RkaW8uaD4KCmludCBtYWluKCkKewogICAgaW50IGksIGosIGQsIG47CgogICAgLy8gdGl0dGxlCiAgICBwcmludGYoIuOAkCDmjpvjgZHnrpfjga7ooajjgpLlh7rjgZfjgb7jgZkg44CRXG4iKTsKICAgIC8vIGlucHV0CiAgICB3aGlsZSAoMSkgewogICAgICAgIHByaW50Zigi5L2V6YCy5pWw44Gu6KGo44KS5Ye644GX44G+44GZ44GLKDLvvZ4xMCkgOiIpOwogICAgICAgIHNjYW5mKCIlZCIsICZuKTsKICAgICAgICBpZiAobiA8IDIgfHwgMTAgPCBuKSB7CiAgICAgICAgICAgIHByaW50Zigi44Ko44Op44O8XG4iKTsKICAgICAgICB9IGVsc2UgewogICAgICAgICAgICBicmVhazsKICAgICAgICB9CiAgICB9CiAgICAvLyBzaG93IGhlYWQKICAgIHByaW50ZigiXG4gICB8ICIpOwogICAgZm9yIChqID0gMTsgaiA8IG47IGorKykgewogICAgICAgIHByaW50ZigiICVkICIsIGopOwogICAgfQogICAgcHJpbnRmKCJcbi0tLSsiKTsKICAgIGZvciAoaiA9IDA7IGogPCAobiAtIDEpICogMyArIDE7IGorKykgewogICAgICAgIHByaW50ZigiLSIpOwogICAgfQogICAgcHJpbnRmKCJcbiIpOwogICAgLy8gc2hvdyBib2R5CiAgICBmb3IgKGkgPSAxOyBpIDwgbjsgaSsrKSAgICAgLy8gbumAsuaVsOOBrjEw44Gu5L2N44Gr44Gk44GE44GmCiAgICB7CiAgICAgICAgcHJpbnRmKCIgJWQgfCAiLCBpKTsKICAgICAgICBmb3IgKGogPSAxOyBqIDwgbjsgaisrKSAvLyBu6YCy5pWw44GuMeOBruS9jeOBq+OBpOOBhOOBpgogICAgICAgIHsKICAgICAgICAgICAgZCA9IGkgKiBqOwogICAgICAgICAgICBkID0gMTAgKiAoZCAvIG4pICsgZCAlIG47CiAgICAgICAgICAgIHByaW50ZigiJTJkICIsIGQpOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICAvLyBlbmQKICAgIHJldHVybiAwOwp9