#include int factorial(int n) { int result = 1; for (int i = 1; i <= n; i++) { result *= i; } return result; } int main() { int n; printf("请输入一个非负整数:"); scanf("%d", &n); printf("%d! = %d\n", n, factorial(n)); return 0; }