Problem Description

输入一个正整数n(n<=10),计算
S=1!+2!+3!+...+n!

Input

输入一个正整数n(n<=10)(多组数据)

Output

输出S(每组数据一行)

Sample Input

2

Sample Output

3

#include<stdio.h>

int main()

{

         long int s,a;

         int i,n;

         while(scanf("%d",&n)!=EOF)

         {

                   s=;

                   a=;

                   for(i=;i<=n;i++)

                   {

                            a=a*i;

                            s=s+a;

                   }

                   printf("%ld\n",s);

         }

         return ;

}

其他代码:

 #include<stdio.h>
int ridsum(int n)
{
int sum,i;
if(n==||n==)
return ;
else
return ridsum(n-)*n;
}
int main()
{
int n,sum,i;
while(scanf("%d",&n)!=EOF)
{
for(i=,sum=;i<=n;i++)
sum+=ridsum(i);
printf("%d\n",sum);
}
return ;
}

武汉科技大学ACM :1002: 零起点学算法38——求阶乘和的更多相关文章

  1. 武汉科技大学ACM :1002: 零起点学算法66——反话连篇

    Problem Description 把输入的字符按照反着顺序输出 Input 多组测试数据  每组一行(每组数据不超过200个字符) Output 按照输入的顺序反着输出各个字符 Sample I ...

  2. 武汉科技大学ACM :1002: 零起点学算法28——判断是否闰年

    Problem Description 输入年份,判断是否闰年 Input 输入一个整数n(多组数据) Output 如果是闰年,输出yes,否则输出no(每组数据一行) Sample Input 2 ...

  3. 武汉科技大学ACM :1010: 零起点学算法12——求2个日期之间的天数

    Problem Description 水题 Input 输入2个日期,日期按照年月日,年月日之间用符号-隔开(题目包含多组数据) Output 求出这2个日期之间的天数(不包括自身),每组测试数据一 ...

  4. 武汉科技大学ACM :1006: 零起点学算法25——求两点之间的距离

    Problem Description 输入平面坐标系中2点的坐标,输出它们之间的距离 Input 输入4个浮点数x1 y1 x2 y2,分别是点(x1,y1) (x2,y2)的坐标(多组数据) Ou ...

  5. Problem Z: 零起点学算法22——求正弦和余弦

    #include<stdio.h> #include <math.h> int main() { int n; ); double a,b; while(scanf(" ...

  6. Problem W: 零起点学算法21——求平均值

    #include<stdio.h> int main() { int a,b,c; scanf("%d %d %d",&a,&b,&c); pr ...

  7. Problem R: 零起点学算法13——求2个时间之间的分钟数

    #include<stdio.h> int main() { int a1,b1,a2,b2,s; scanf("%d:%d",&a1,&b1); sc ...

  8. Problem Q: 零起点学算法12——求2个日期之间的天数

    #include<stdio.h> int main() { int a1,b1,c1,a2,b2,c2,s; scanf("%d-%d-%d",&a1,&am ...

  9. Problem O: 零起点学算法10——求圆柱体的表面积

    #include<stdio.h> int main() { float r,h,pi; pi=3.1415926; scanf("%f %f",&r,& ...

随机推荐

  1. PHP之路——验证码实现

    验证码生成并保存到session <?php //开始session session_start(); //画布大小 $image = imagecreate(100, 40); $color ...

  2. Word中封面的问题

    老师给了封面,当从一个文档复制到另一个文档时格式变了,即便用格式刷也解决不了一些问题,那么就把正文复制到带有封面的文档,把老师的其他内容删掉.

  3. <frameset><frame><iframe>网页框架

    这几个标签都属于同一类功能,就是框架内镶功能: 1)<frameset>意为把页面分解成一定部分,让每一部分显示不同的内镶框架,如(请复制到DW尝试): <html> < ...

  4. 【Express】路由

    var express = require('express'); var app = express(); app.set('port', process.env.PORT || 3000); ap ...

  5. Delphi自定义消息应用及delphi托盘实现

    Delphi自定义消息应用及delphi托盘实现interfaceuses   Windows, Messages, SysUtils, Variants, Classes, Graphics, Co ...

  6. rails console --sandbox出现的安装错误解决方案

    rails中可以用使用console命令行来测试运行rails应用程序,但是采用源码编译安装的话可能缺少readline动态库,导致ruby无法使用这个库此时如果调用rails console(rai ...

  7. Unity3D基础学习之AssetBundle 资源包创建与加载

    前几天做了AssentBundle的例子,遇到了问题,在论坛上问了三天都没人解答,最后在一个朋友的帮助下解决了.下面介绍AssentBundle. AssetBundles让你通过WWW类流式加载额外 ...

  8. 针对Yii框架的nginx配置

    我曾经针对yii制作了 个nginx配置,其中包括了以下几项内容: rewrite规则(try_file),需要nginx0.8.6版本以上支持. 针对于icon, robots.txt文件的日志优化 ...

  9. Remember the Word,LA3942(Trie树+DP)

    Trie树基础题,记录下代码. #include <cstdio> #include <cstring> #define MaxNode 4005*100 #define No ...

  10. ServletContextListener 解析用法

    ServletContext 被 Servlet 程序用来与 Web 容器通信.例如写日志,转发请求.每一个 Web 应用程序含有一个Context,被Web应用内的各个程序共享.因为Context可 ...