下面的程序从用户那里获取一个整数输入,并生成多达 10 的乘法表。
#include <stdio.h>
int main() {
  int n, i;
  printf("Enter an integer: ");
  scanf("%d", &n);
  for (i = 1; i <= 10; ++i) {
    printf("%d * %d = %d \n", n, i, n * i);
  }
  return 0;
}
结果:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Enter an integer: 8 8 * 1 = 8 8 * 2 = 16 8 * 3 = 24 8 * 4 = 32 8 * 5 = 40 8 * 6 = 48 8 * 7 = 56 8 * 8 = 64 8 * 9 = 72 8 * 10 = 80 Process returned 0 (0x0) execution time : 1.964 s Press any key to continue. | 
除教程外,本网站大部分文章来自互联网,如果有内容冒犯到你,请联系我们删除!
