24.While循环

/*
赋值运算符(又叫改变运算符,当表达式中有这几种
运算符出现时,我们就要考虑某一个或某几个变量的
值被改变了):

=
+= x+=5; x=x+5; 累加
-=
*= 累乘
/=
%= %运算的两边必须是整型

阶乘:
5!=5*4*3*2*1
10!=10*9*8*7*6*5*4*3*2*1

*/
#include "stdio.h"
void main()
{
int x,sj,n;

printf("你要计算几得阶乘?");
scanf("%d",&n);

sj=1;
for(x=n;x>=1;x--)
{
sj=sj*x;
}

printf("%d的阶乘是:%d\n",n,sj);
}

posted @ 2018-05-08 09:45  我喜欢空格键  阅读(110)  评论(0编辑  收藏  举报