C语言 编程求1到10的阶乘 分别显shi
时间: 2024-05-08 20:15:09 浏览: 95
以下是C语言代码:
```c
#include <stdio.h>
int main() {
int i, j, factorial;
for (i = 1; i <= 10; i++) {
factorial = 1;
for (j = 1; j <= i; j++) {
factorial *= j;
}
printf("%d! = %d\n", i, factorial);
}
return 0;
}
```
输出结果:
```
1! = 1
2! = 2
3! = 6
4! = 24
5! = 120
6! = 720
7! = 5040
8! = 40320
9! = 362880
10! = 3628800
```
阅读全文