#include <stdio.h>

int main() {
    int n, i;
    long long fact = 1;

    printf("请输入一个正整数:");
    scanf("%d", &n);

    if (n < 0) {
        printf("错误:输入的数必须是正整数。\n");
        return 0;
    }

    for (i = 1; i <= n; ++i) {
        fact *= i;
    }

    printf("%d 的阶乘是 %lld。\n", n, fact);

    return 0;
}
用c语言编写一个计算阶乘的程序

原文地址: https://www.cveoy.top/t/topic/bEIM 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录