?? 008.c
字號:
#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 + -