如何用C语言计算1!+2!+·····n!值
1、用for循环来计算#include<stdio.h>int main(){int n,b,c,x,y;y=0;printf("请输入一个数:");scanf("%d",&n);for(b=1;b<n+1;b++){for(c=1,x=1;c<=b;c++)x=x*c;y=y+x;}printf("1!+2!+·····%d!的值为:%d\n",n,y);return 0;}
声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:65
阅读量:39
阅读量:40
阅读量:27
阅读量:80