zoukankan      html  css  js  c++  java
  • N!

    Problem Description

    Given an integer N(0 ≤ N ≤ 10000), your task is to calculate N!

    Input

    One N in one line, process to the end of file.

    Output

    For each N, output N! in one line.

    Sample Input

    1
    2
    3
    

    Sample Output

    1
    2
    6
    

    Author

    JGShining(极光炫影)

    #include<iostream>
    #include<string.h>


    using namespace std;
    int a[100000];
    int main()int 
    {
    int i,j;
    int n;
    while(cin>>n)
    {
       memset(a,0,sizeof(a));
       a[0]=1;
       int s,count=1;
       for(i=1;i<=n;i++)
       {
       s=0;
        for(j=0;j<count;j++)
        {
         a[j]=a[j]*i+s;
         s=a[j]/10;
         a[j]=a[j]%10;
        }
        while(s)
        {
         a[count]=s%10;
         s=s/10;
         count++;
        }
       }
       for(i=count-1;i>=0;i--)
        cout<<a[i];
       cout<<endl;
    }
    return 0;
    }

  • 相关阅读:
    AJAX需要注意的
    SEO 搜索引擎优化
    jQuery 插件
    CSS BFC和IE Haslayout
    jQuery 插件开发
    jQuery Ajax
    jQuery 工具函数
    jQuery 动画效果
    jQuery 高级事件
    jQuery 事件对象
  • 原文地址:https://www.cnblogs.com/lengxia/p/4387870.html
Copyright © 2011-2022 走看看