# Factorial

109人阅读 评论(0)

## 题目描述

Homelesser hates mathematics. He cannot even do addition and subtraction, not to mention computing factorial. He asks Cainiao2hao for help. Cainiao2hao is always busy solving more difficult problems. And now, please help Homelesser to compute factorial. If you cannot do it well, Cainiao2hao will think you are as fool as Homelesser.

## 输入

The first line contains only one integer T (T is about 10) indicates the number of test cases. For each case there are one integer n (0 ≤ n ≤ 10).

## 输出

One line for each case specifying the factorial of n.

## 示例输入

2
4
3

## 示例输出

24
6

## 来源

2014年山东省第五届ACM大学生程序设计竞赛

## 示例程序

#include<stdio.h>
int main()
{
int i,j,n,m,k,t,f1,f2;
scanf("%d",&n);
for(i=0;i<n;i++)
{
f1=1;
scanf("%d",&m);
if(m==0)
printf("%d\n",f1);
if(m>=1)
{
for(j=1;j<=m;j++)
{
f2=f1*j;
f1=f2;
}
printf("%d\n",f2);
}
}
} 

0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：150796次
• 积分：7122
• 等级：
• 排名：第3272名
• 原创：584篇
• 转载：33篇
• 译文：0篇
• 评论：6条
评论排行
最新评论