bshy.net
当前位置:首页>>关于编写程序,输入正整数n,计算它的阶乘! (n!=n×...的资料>>

编写程序,输入正整数n,计算它的阶乘! (n!=n×...

#include void main(){int i,n,k=1;scanf("%d",&n);for(i=1;i

INPUT "请输入一个正整数";n i=n t=1 DO t=t*n i=i-1 LOOPUNTIL i=0 PRINT t END

Private Sub Form_click() Dim n As Double, s As Double n = Val(InputBox("输入一个数")) s = 1 For i = 1 To n s = s * i Next MsgBox s End Sub

http://blog.163.com/asm_c/blog/static/24820311320120107440376/ 这就是。

#includevoid main(){int n,m,i;printf("输入n的值:"); scanf("%d",&n);if(n==0||n==1){m=1;printf("n的阶乘为:%d\n",m);}else{m=1;for(i=n;i>0;i--)m=m*i;printf("n的阶乘为:%d\n",m);}}//刚写的,运行通过

int n,m=1,i; scanf(“%d”,&n); for(i=0,i<=n?;i++) m=n*m;

用递归

#include int main() { int num; printf("input num"); scanf("%d",&num); int Sum=1; for(int i=1;i

#include void main(){ int i,a,sum=1; scanf ("%d",&a); for(i=1;i

long fac(int k) //{ long result=1; // int i; for (i=2;i

网站首页 | 网站地图
All rights reserved Powered by www.bshy.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com