计算阶乘 用循环实现

来源:互联网 发布:mysql分布式数据库搭建 编辑:程序博客网 时间:2024/05/14 10:27
#include <stdio.h>int main(){    int a, i;    int b = 1;        printf("%s", "Enter the Num: ");    scanf("%d", &a);        for (i = a; i >= 1; i--){        b = b * i;    }        printf("%d\n", b);        return 0;}#include<stdio.h>int main(){    int a, b;    printf("%s", "Enter the Num: ");    scanf("%d", &a);    b = a;    for (size_t i = 1; i < a; i++){        b = b * (a - i);    }    printf("%d", b);    return 0;}


0 0
原创粉丝点击