n!的另类算法

来源:互联网 发布:淘宝卖家地址哪里改 编辑:程序博客网 时间:2024/05/16 07:36
#include <stdio.h>                //归结于递归问题 
#include <stdlib.h>


static int ret = 1;
static int n = 0;
int han(int s)
{   
   if( s > 0 )
   {
han(s-1);  
n = n + 1;
ret = ret * n; 
   }
   return ret;
}


int main(int argc, char *argv[])
{
    han(4);
    printf("%d",ret);
return 0;
}
0 0
原创粉丝点击