2014山东省第五届ACM省赛 Factorial

Factorial

Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

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 <iostream>   
using namespace std;   
int main()   
{   
    int T;   
    cin>>T;   
    while(T--)   
    {   
        int n;   
        cin>>n;   
        int sum=1;   
        for(int i=2;i<=n;i++)   
            sum*=i;   
        cout<<sum<<endl;   
    }   
    return 0;   
}  

你可能感兴趣的:(2014山东省第五届ACM省赛 Factorial)