运行结果:

C语言代码:
/* c how to program 习题4.14 ** 计算1-5的阶乖 */ #include <stdio.h> #include <math.h> // function main begins program execution int main( void ) { //定义变量x为整数,n为阶乘 int x, n = 1; //使用循环计算阶乖 printf("计算x的阶乖(x!):\nx\tx!\n"); for(x = 1; x <= 5; x++){ n *= x; //打印结果 printf("%d\t%d\n", x, n); } }