Compare commits

..

2 Commits

Author SHA1 Message Date
19ac0b6144 course(递归专题)求累加和 2020-04-24 13:51:38 +08:00
e862efa6c7 微调 2020-04-24 13:51:21 +08:00
11 changed files with 64 additions and 7 deletions

View File

@ -5,7 +5,7 @@ long long dg(long long n){
if(n==1){
return 1;
}
return n+dg(n-1);
return n*dg(n-1);
}
int main()
{

Binary file not shown.

View File

@ -1,18 +1,18 @@
## z:\Chao\src\1659_n!\test\in.txt
2020/04/24 周五 13:42:16.59
2020/04/24 周五 13:46:26.28
1
-----------------------------------------------
Process exited after 190 ms with return value 0
Process exited after 140 ms with return value 0
## z:\Chao\src\1659_n!\test\in2.txt
2020/04/24 周五 13:42:16.59
2020/04/24 周五 13:46:26.28
1307674368000
-----------------------------------------------
Process exited after 100 ms with return value 0
Process exited after 90 ms with return value 0
## z:\Chao\src\1659_n!\test\in3.txt
2020/04/24 周五 13:42:16.59
2020/04/24 周五 13:46:26.28
24
-----------------------------------------------
Process exited after 110 ms with return value 0
Process exited after 180 ms with return value 0

3
1660_n+/Readme.md Normal file
View File

@ -0,0 +1,3 @@
# 标题
* 内容

18
1660_n+/doc/Readme.md Normal file
View File

@ -0,0 +1,18 @@
# 『入门』(递归专题)求累加和
[问题描述]
教学案例,必须使用递归函数完成求解!
  编程求解下列式子的值s=1+2+3+...+n。
[输入格式]
  一行只有一个整数n。(1 <= n <= 1000)
[输出格式]
  1个整数即s的值。
[输入样例]
100
[输出样例]
5050

15
1660_n+/main.cpp Normal file
View File

@ -0,0 +1,15 @@
//½×¼Ó£¨³¬Ð¡£©
#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 Normal file

Binary file not shown.

1
1660_n+/test/in.txt Normal file
View File

@ -0,0 +1 @@
1

1
1660_n+/test/in2.txt Normal file
View File

@ -0,0 +1 @@
100

1
1660_n+/test/in3.txt Normal file
View File

@ -0,0 +1 @@
1000

18
1660_n+/test/out.txt Normal file
View File

@ -0,0 +1,18 @@
## 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