Compare commits
No commits in common. "19ac0b6144f5ec6bcd1aec92a0ba327972e041b2" and "af24f23707c8ee1902edda2ced52b684d6bcc1b0" have entirely different histories.
19ac0b6144
...
af24f23707
@ -5,7 +5,7 @@ long long dg(long long n){
|
|||||||
if(n==1){
|
if(n==1){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return n*dg(n-1);
|
return n+dg(n-1);
|
||||||
}
|
}
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
|
BIN
1659_n!/main.exe
BIN
1659_n!/main.exe
Binary file not shown.
@ -1,18 +1,18 @@
|
|||||||
## z:\Chao\src\1659_n!\test\in.txt
|
## z:\Chao\src\1659_n!\test\in.txt
|
||||||
2020/04/24 周五 13:46:26.28
|
2020/04/24 周五 13:42:16.59
|
||||||
1
|
1
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 140 ms with return value 0
|
Process exited after 190 ms with return value 0
|
||||||
|
|
||||||
## z:\Chao\src\1659_n!\test\in2.txt
|
## z:\Chao\src\1659_n!\test\in2.txt
|
||||||
2020/04/24 周五 13:46:26.28
|
2020/04/24 周五 13:42:16.59
|
||||||
1307674368000
|
1307674368000
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 90 ms with return value 0
|
Process exited after 100 ms with return value 0
|
||||||
|
|
||||||
## z:\Chao\src\1659_n!\test\in3.txt
|
## z:\Chao\src\1659_n!\test\in3.txt
|
||||||
2020/04/24 周五 13:46:26.28
|
2020/04/24 周五 13:42:16.59
|
||||||
24
|
24
|
||||||
-----------------------------------------------
|
-----------------------------------------------
|
||||||
Process exited after 180 ms with return value 0
|
Process exited after 110 ms with return value 0
|
||||||
|
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
# 标题
|
|
||||||
|
|
||||||
* 内容
|
|
@ -1,18 +0,0 @@
|
|||||||
# 『入门』(递归专题)求累加和
|
|
||||||
[问题描述]
|
|
||||||
|
|
||||||
教学案例,必须使用递归函数完成求解!
|
|
||||||
|
|
||||||
编程求解下列式子的值:s=1+2+3+...+n。
|
|
||||||
|
|
||||||
[输入格式]
|
|
||||||
一行,只有一个整数n。(1 <= n <= 1000)
|
|
||||||
|
|
||||||
[输出格式]
|
|
||||||
1个整数,即s的值。
|
|
||||||
|
|
||||||
[输入样例]
|
|
||||||
100
|
|
||||||
|
|
||||||
[输出样例]
|
|
||||||
5050
|
|
@ -1,15 +0,0 @@
|
|||||||
//½×¼Ó£¨³¬Ð¡£©
|
|
||||||
#include <iostream>
|
|
||||||
using namespace std;
|
|
||||||
long long dg(long long n){
|
|
||||||
if(n==1){
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return n+dg(n-1);
|
|
||||||
}
|
|
||||||
int main()
|
|
||||||
{
|
|
||||||
int n;
|
|
||||||
cin>>n;
|
|
||||||
cout<<dg(n);
|
|
||||||
}
|
|
BIN
1660_n+/main.exe
BIN
1660_n+/main.exe
Binary file not shown.
@ -1 +0,0 @@
|
|||||||
1
|
|
@ -1 +0,0 @@
|
|||||||
100
|
|
@ -1 +0,0 @@
|
|||||||
1000
|
|
@ -1,18 +0,0 @@
|
|||||||
## z:\Chao\src\1660_n+\test\in.txt
|
|
||||||
2020/04/24 周五 13:47:20.56
|
|
||||||
1
|
|
||||||
-----------------------------------------------
|
|
||||||
Process exited after 160 ms with return value 0
|
|
||||||
|
|
||||||
## z:\Chao\src\1660_n+\test\in2.txt
|
|
||||||
2020/04/24 周五 13:47:20.56
|
|
||||||
5050
|
|
||||||
-----------------------------------------------
|
|
||||||
Process exited after 80 ms with return value 0
|
|
||||||
|
|
||||||
## z:\Chao\src\1660_n+\test\in3.txt
|
|
||||||
2020/04/24 周五 13:47:20.56
|
|
||||||
500500
|
|
||||||
-----------------------------------------------
|
|
||||||
Process exited after 80 ms with return value 0
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user