0):"**输出格式要求:"%d! = %lu\n"_利用求阶乘函数fact(),编程计算并输出1! + 2! + …+ n!的值。 **输入格式要求:"%u">
赞
踩
利用求阶乘函数Fact(),编程计算并输出从1到n之间所有数的阶乘值。 **输入格式要求:"%u" 提示信息:"Input n(n>0):" **输出格式要求:"%d! = %lu\n" 程序运行示例如下: Input n(n>0):10 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880 10! = 3628800
- #include<stdio.h>
- long Func(int n);
- int main()
- {
- int i, n;
- printf("Input n(n>0):");
- scanf("%u", &n);
- for (i = 1; i <= n; i++)
- {
- printf("%d! = %lu\n", i, Func(i));
-
- }
- return 0;
- }
- long Func(int n)
- {
- static long p = 1;
- p = p * n;
- return p;
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。