Skip to content

Commit fe464a8

Browse files
author
lazylzg
committed
更新第8章
1 parent 973ba70 commit fe464a8

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

第8章递归与分治/8.1递归策略/8-2汉诺塔Ⅲ.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include<iostream>
2-
32
using namespace std;
4-
53
long long fac(int n) {
64
if(n==1) {
75
return 2;

第8章递归与分治/8.1递归策略/test8-1杨辉三角形.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include<iostream>
2-
32
using namespace std;
4-
53
int fun(int x,int y) {
64
if(y==1||x==y) {
75
return 1;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#include<iostream>
2+
#include<algorithm>
3+
using namespace std;
4+
void pailie(string &str,int s,int t) {
5+
if(s==t) {
6+
cout<<str<<endl;
7+
return;
8+
} else {
9+
for(int i=s; i<=t; i++) {
10+
swap(str[s],str[i]);
11+
pailie(str,s+1,t);
12+
swap(str[s],str[i]);
13+
}
14+
}
15+
}
16+
int main() {
17+
string str;
18+
while(getline(cin,str)) {
19+
sort(str.begin(),str.end());
20+
pailie(str,0,str.size()-1);
21+
}
22+
return 0;
23+
}

第8章递归与分治/8.2分治法/8-3Fibonacci.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#include<iostream>
2-
32
using namespace std;
4-
53
int Fibonacci(int n) {
64
if(n==0||n==1) {
75
return n;

第8章递归与分治/8.2分治法/8-4二叉树.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include<iostream>
2-
32
using namespace std;
43
/**
54
二叉树

第8章递归与分治/8.2分治法/test8-3 2的幂次方.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ using namespace std;
88

99
void print(int num) {
1010
int i=0;
11-
while(pow(2,i)<=num) {
12-
i++;
13-
}
11+
while(pow(2,i)<=num)i++;
1412
i--;
1513
if(i==0) {
1614
printf("2(0)");

0 commit comments

Comments
 (0)