⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 C语言实战105例源码--私藏很久的源码.zip
💻
字号:

#include<stdio.h>
#include<stdlib.h>
int main()
{
	int i = 0;/* i为计数器 */
	int n;
	int factorial = 1;/* 保存阶乘的结果 */
	puts("*************************************");
	puts("*      The program will compute     *");
	puts("*    the factotial of an integer    *");
	puts("*************************************");
	puts("please input the number n:");
	scanf("%d",&n);
	if(n < 0)/*判断输入的书是否大于或等于0*/
	{
	  	printf("please input an interger >= 0.\n");
	    return 0;
	}
	if(n==0)/* 0的阶乘是1 */
	{
	    printf("factorial of 0 is 1.\n");
	    return 0;
	}
	i = 1;
    while(i <= n)
    {
    	factorial = factorial * i;
    	i++;
    }
    printf("factorial of %d is:%d.\n",n,factorial);
    getch();
    return 0;
	
}

 
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -