『代码』··By/蜜汁炒酸奶

数的阶乘计算器

/* 功能:数的阶乘计算器 日期:2013-4-19 */ #include <stdio.h> #include <stdlib.h> #include<math.h> int main(void) { int x,i=0,t=1; printf(“请输入需要计算阶乘的数字:”); scanf(“%d”,&x); for (i=1,t=1;i<=x;i++) { if (x<0) {do { printf(“Error,请重新输入:”); scanf(“%d”,&x); }while(x>0); } else { t=t*i; } } printf(“%d的阶乘是:%dn”,x,t); system(“pause”); return 0; }

预览
Loading comments...
0 条评论

暂无数据

example
预览