zoukankan      html  css  js  c++  java
  • c语言 8-7

    1、

    #include <stdio.h>
    
    int fac(int x)
    {
        if(x > 0)
            return x * fac(x - 1);
        else
            return 1; 
    }
    
    int main(void)
    {
        int a, b;
        puts("please input two integers.");
        printf("a = "); scanf("%d", &a);
        printf("b = "); scanf("%d", &b);
        
        printf("result:  %d
    ", fac(a)/(fac(b)*fac(a - b)));
        
        return 0;
    }

    2、

    #include <stdio.h>
    
    int fac(int x)
    {
        if(x > 0)
            return x * fac(x - 1);
        else
            return 1;
    }
    
    int main(void)
    {
        int a, b;
        puts("please input two integers.");
        do
        {
            printf("a = "); scanf("%d", &a);
            if(a < 0)
            {
                puts("the range of a >= 0.");
                continue;
            }
            printf("b = "); scanf("%d", &b);
            if(b < 0)
            {
                puts("the range of b >= 0.");
                continue;
            }
            if(a < b)
                puts("a should >= b.");
        }
        while( a < b || a < 0 || b < 0);
        
        puts("==========
    ");
        printf("the result: %d
    ", fac(a)/(fac(b) * fac(a - b)));
        
        return 0;
    }

  • 相关阅读:
    高一下期末考试划水记
    BZOJ 1053
    积性函数与狄利克雷卷积(未完待更)
    Contest Hunter 3101
    POJ2689
    3.17爆零赛
    全概率公式
    矩阵快速幂
    模板练习
    _rqy's Code Style for OI
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14800163.html
Copyright © 2011-2022 走看看