![](https://img-blog.csdnimg.cn/20201014180756913.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法设计与分析
我不学习机器学习
这个作者很懒,什么都没留下…
展开
-
算法设计与分析-dfs
13-1.cpp#include<iostream>#include<cmath>using namespace std;const int N = 20;int a[N];int Prime(int x) { int i, n; n = (int)sqrt(x); for (i = 2; i < n; i++) { if (x % i == 0) { return 0; } } return 1;}int Check(int k, in原创 2021-05-21 11:17:12 · 219 阅读 · 2 评论 -
算法设计与分析-greedy
12-3.cpp#include<iostream>using namespace std;const int n = 5;int arc[100][100];int color[100];int Ok(int i) { for (int j = 0; j < n; j++) { if (arc[i][j] == 1 && color[i] == color[j]) { return 0; } return 1; }}void Colo原创 2021-05-21 11:16:14 · 129 阅读 · 0 评论 -
算法设计与分析-dp666
9-2.cpp#include<iostream>using namespace std;const int n = 5;int DataTower(int d[n][n]) { int maxAdd[n][n] = { 0 }, path[n][n] = { 0 }; int i, j; for (j = 0; j < n; j++) { maxAdd[n - 1][j] = d[n - 1][j]; } for (i = n - 2; i >= 0; i--原创 2021-04-21 12:41:51 · 231 阅读 · 0 评论 -
算法设计与分析-Search
7-2.cpp#include<iostream>using namespace std;int SearchMid(int A[], int B[], int n) { int s1 = 0, e1 = n - 1, s2 = 0, e2 = n - 1; int mid1, mid2; while (s1 < e1 && s2 < e2) { mid1 = (s1 + e1) / 2; mid2 = (s2 + e2) / 2; if (A原创 2021-04-07 21:56:24 · 168 阅读 · 0 评论 -
算法设计与分析-Conquer
5-1.cpp#include<iostream>#include<iomanip>using namespace std;int data[100][100];void Full(int number, int begin, int size) { int i, j, k; if (size == 0) { return; } if (size == 1) { data[begin][begin] = number; return; } i = b原创 2021-03-30 22:26:11 · 163 阅读 · 0 评论 -
算法设计与分析-BruteForce
3-2.cpp#include<iostream>using namespace std;int BF(char S[], char T[]) { int index = 0; int i = 0, j = 0; while ((S[i] != '\0') && (T[j] != '\0')) { if (S[i] == T[j]) { i++; j++; } else { index++; i = index; j = 0;原创 2021-03-13 13:03:25 · 210 阅读 · 0 评论 -
算法设计与分析-Analyse
2-3.cpp#include<iostream>#include<cmath>using namespace std;int main() { system("color FD"); double sum = 0; for (int i = 1; i <= 64; i++) { sum += pow(2, i - 1); } cout << sum << endl;}原创 2021-03-13 13:00:44 · 159 阅读 · 0 评论 -
算法设计与分析-Algorithm
1-1.cpp#include<iostream>using namespace std;int CommFactor2(int m, int n) { int r = m % n; while (r != 0) { m = n; n = r; r = m % n; } return n;}int main() { system("color FD"); int a, b, c; cout << "请输入两个自然数:" << endl;原创 2021-03-05 22:30:07 · 139 阅读 · 0 评论